使用c#将消息发布到tibco jms队列

时间:2015-10-26 06:58:10

标签: c# jms tibco

我有以下信息:

`JNDIFactoryClass - com.tibco.tibjms.naming.TibjmsInitialContextFactory`
`JNDIServiceURL - tibjmsnaming://<Host>:<PORT>`
`JMSConnectionFactory - A**.**.***.COMMON.QCF.MS`
`UserName - <UserName>`
`Password - <Password>`
`QUEUEName - <QUEUENAME>`

我必须使用c#将消息发布到此队列。请帮忙

我尝试过使用weblogic.messaging dll,但它没有用

添加了以下代码:

IDictionary<string, Object> paramMap = new Dictionary<string, Object>();

            // add necessary properties

            paramMap[WebLogic.Messaging.Constants.Context.PROVIDER_URL] = txtJNDIServiceURL.Text; //"t3://" + host + ":" + port;

            paramMap[WebLogic.Messaging.Constants.Context.SECURITY_PRINCIPAL] = txtJMSUserName.Text;//username;

            paramMap[WebLogic.Messaging.Constants.Context.SECURITY_CREDENTIALS] = txtJMSPassword.Text;


            // get the initial context


            IContext context = ContextFactory.CreateContext(paramMap);



            // lookup the connection factory

            IConnectionFactory cf = context.LookupConnectionFactory(txtJNDIFactoryClass.Text);

            // lookup the queue

            IQueue queue = (IQueue)context.LookupDestination(txtJMSQueue.Text);

            // create a connection

            IConnection connection = cf.CreateConnection();

            // start the connection

            connection.Start();

            // create a session

            ISession session = connection.CreateSession(

            WebLogic.Messaging.Constants.SessionMode.AUTO_ACKNOWLEDGE);

            // create a message producer

            IMessageProducer producer = session.CreateProducer(queue);

            producer.DeliveryMode = WebLogic.Messaging.Constants.DeliveryMode.PERSISTENT;

            // create a text message

            ITextMessage textMessage = session.CreateTextMessage(rtbTriggerMsg.Text);

            // send the message

            producer.Send(textMessage);

            // CLEAN UP

            connection.Close();

            context.CloseAll();

0 个答案:

没有答案