Configure Hornetq to connect to Websphere MQ
mabma Aug 2, 2011 5:35 AMHi,
I'm new to JMS and HornetQ and have some question about configuring HornetQ.
I want to send messages to a Websphere MQ und use a standalone HornetQ server.
Therefore I followed the EmbeddedSimple-Example in the jms-examples-folder.
My problem is now how to set up the hornetq-configuration.xml and hornetq-jms.xml.
I've read several posts on JBoss and Websphere, where the wmq.jmsra.rar is used in the configuration. But I don't know how to translate that for my simple example.
I copied the jars from the rar-file to my buildpath to use the connectionFactory.
My hornetq-configuration.xml contains the following:
<connectors> <connector name="MQC" > <factory-class>com.ibm.mq.jms.MQQueueConnectionFactory</factory-class> <param key="channel" value="CHANNEL1" /> <param key="hostName" value="MQS.MYSERVER.DE" /> <param key="port" value="1415" /> <param key="queueManager" value="CSQT" /> <param key="transportType" value="CLIENT" /> </connector> </connectors>
the hornetq-jms.xml
<connection-factory name="MQF"> <connectors> <connector-ref connector-name="MQC"/> </connectors> <entries> <entry name="MQF"/> </entries> </connection-factory> <queue name="LOCAL.QUEST01.T.QUEUE"> <entry name="MQSQueue"/> </queue>
The Example is very simple:
EmbeddedJMS jmsServer = new EmbeddedJMS(); jmsServer.start(); ConnectionFactory cf = (ConnectionFactory)jmsServer.lookup("MQF"); Queue queue = (Queue)jmsServer.lookup("MQSQueue"); // Step 10. Send and receive a message using JMS API Connection connection = null; try { connection = cf.createConnection(); Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); MessageProducer producer = session.createProducer(queue); TextMessage message = session.createTextMessage("Hello sent at " + new Date()); ... } ...
When running the example a ConnectionFactory and Queue is set from the configuration, but when creating a Connection on the connectionfactory, a classCastException appers (com.ibm.mq.jms.MQQueueConnectionFactory cannot be cast to org.hornetq.spi.core.remoting.ConnectorFactory).
I hope someone has done something like this before and can give me a hint how to configure the connector.
Greetings
Marc