【发布时间】:2017-07-24 20:31:40
【问题描述】:
大家好,我正在开发一个 JMS 客户端。我了解我的 JMS 资源,即 ConnectionFactory、QueueConnectionFactory 和 Queue/Topic。我已经使用 java 开发了它,它在我使用 glassfish 的本地服务器机器上运行良好。
我想确定我从这个路由点收到的 Connectionfactory 或 QueueConnectionFactory 是什么。我将如何实现连接到 VPN 服务器。 CSD 端口为 7016,CSD IP:10.10.10.76
<routingPoint>
<name>CSD</name>
<inboundQueue>interfaceCsdOut</inboundQueue>
<outboundQueue>interfaceCsdIn</outboundQueue>
<context>glassfish-csd</context>
<matchingKey>DESTINATION</matchingKey>
<controlPoint>SWITCH</controlPoint>
</routingPoint>
这是我用来连接本地机器的 java 代码的 sn-p。
Properties props = new Properties();
props.put(Context.PROVIDER_URL, "mq://127.0.0.1:7676");
// Create the initial context for remote JMS server
InitialContext cntxt = new InitialContext(props);
//System.out.println("Context Created");
// JNDI Lookup for QueueConnectionFactory in remote JMS Provider
QueueConnectionFactory qFactory = (QueueConnectionFactory)cntxt.lookup("TestQueueConnectionFactory");
// Create a Connection from QueueConnectionFactory
Connection connection = qFactory.createConnection();
//System.out.println("Connection established with JMS Provider ");
// Initialise the communication session
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the message
TextMessage message = session.createTextMessage();
message.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
message.setText(finalm);
// JNDI Lookup for the Queue in remote JMS Provider
Queue queue = (Queue)cntxt.lookup("jms/Escrow");
// Create the MessageProducer for this communication
// Session on the Queue we have
MessageProducer mp = session.createProducer(queue);
// Send the message to Queue
mp.send(message);
//System.out.println(finalm);
// Make sure all the resources are released
mp.close();
session.close();
cntxt.close();
【问题讨论】: