Created
February 23, 2016 05:37
-
-
Save jyukutyo/75c2869c8f5820c5cb65 to your computer and use it in GitHub Desktop.
HornetQ Directly instantiating JMS Resources without using JNDI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grapes([ | |
@Grab(group='org.hornetq', module='hornetq-native', version='2.4.7.Final'), | |
@Grab(group='org.hornetq', module='hornetq-core-client', version='2.4.7.Final'), | |
@Grab(group='org.hornetq', module='hornetq-jms-client', version='2.4.7.Final'), | |
@Grab(group='jboss', module='jnp-client', version='4.2.2.GA'), | |
@Grab(group='javax.jms', module='jms', version='1.1') | |
]) | |
import javax.jms.* | |
import org.hornetq.api.core.* | |
import org.hornetq.core.remoting.impl.netty.* | |
import org.hornetq.api.jms.* | |
Map<String, Object> connectionParams = new HashMap<String, Object>(); | |
connectionParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.HOST_PROP_NAME, "localhost"); | |
connectionParams.put(org.hornetq.core.remoting.impl.netty.TransportConstants.PORT_PROP_NAME, 5445); | |
TransportConfiguration transportConfiguration = new TransportConfiguration(NettyConnectorFactory.class.getName(), connectionParams); | |
ConnectionFactory cf = HornetQJMSClient.createConnectionFactoryWithoutHA(JMSFactoryType.CF, transportConfiguration); | |
Queue helloQueue = HornetQJMSClient.createQueue("hello"); | |
Connection connection = cf.createConnection(); | |
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); | |
connection.start(); | |
TextMessage message = session.createTextMessage("This is an order"); | |
MessageProducer producer = session.createProducer(helloQueue); | |
producer.send(message); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment