use of javax.jms.MessageProducer in project quickstarts by jboss-switchyard.
the class JMSClient method sendToHornetQ.
private static void sendToHornetQ() throws Exception {
HornetQMixIn hqMixIn = new HornetQMixIn(false).setUser(HQ_USER).setPassword(HQ_PASSWD);
hqMixIn.initialize();
Session session = null;
try {
session = hqMixIn.createJMSSession();
final MessageProducer producer = session.createProducer(HornetQMixIn.getJMSQueue(QUEUE_NAME));
Message message = hqMixIn.createJMSMessageFromResource(MESSAGE_PAYLOAD);
producer.send(message);
System.out.println("Message sent. Please see server console output");
} finally {
hqMixIn.uninitialize();
}
}
use of javax.jms.MessageProducer in project camel by apache.
the class Jms2ObjectFactory method createMessageProducer.
@Override
public MessageProducer createMessageProducer(Session session, Destination destination, boolean persistent, long ttl) throws Exception {
MessageProducer messageProducer = session.createProducer(destination);
messageProducer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
if (ttl > 0) {
messageProducer.setTimeToLive(ttl);
}
return messageProducer;
}
use of javax.jms.MessageProducer in project camel by apache.
the class SjmsProducer method doCreateProducerModel.
protected MessageProducerResources doCreateProducerModel(Session session) throws Exception {
MessageProducerResources answer;
try {
MessageProducer messageProducer = getEndpoint().getJmsObjectFactory().createMessageProducer(session, getEndpoint());
answer = new MessageProducerResources(session, messageProducer, getCommitStrategy());
} catch (Exception e) {
log.error("Unable to create the MessageProducer", e);
throw e;
}
return answer;
}
use of javax.jms.MessageProducer in project camel by apache.
the class Jms11ObjectFactory method createMessageProducer.
public MessageProducer createMessageProducer(Session session, Destination destination, boolean persistent, long ttl) throws Exception {
MessageProducer messageProducer = session.createProducer(destination);
messageProducer.setDeliveryMode(persistent ? DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT);
if (ttl > 0) {
messageProducer.setTimeToLive(ttl);
}
return messageProducer;
}
use of javax.jms.MessageProducer in project pinpoint by naver.
the class ActiveMQClientITBase method testTopicPull.
@Test
public void testTopicPull() throws Exception {
// Given
final String testTopicName = "TestPullTopic";
final ActiveMQTopic testTopic = new ActiveMQTopic(testTopicName);
final String testMessage = "Hello World for Topic!";
// create producer
ActiveMQSession producerSession = ActiveMQClientITHelper.createSession(getProducerBrokerName(), getProducerBrokerUrl());
MessageProducer producer = new MessageProducerBuilder(producerSession, testTopic).waitTillStarted().build();
final TextMessage expectedTextMessage = producerSession.createTextMessage(testMessage);
// create 2 consumers
ActiveMQSession consumer1Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
MessageConsumer consumer1 = new MessageConsumerBuilder(consumer1Session, testTopic).waitTillStarted().build();
ActiveMQSession consumer2Session = ActiveMQClientITHelper.createSession(getConsumerBrokerName(), getConsumerBrokerUrl());
MessageConsumer consumer2 = new MessageConsumerBuilder(consumer2Session, testTopic).waitTillStarted().build();
// When
producer.send(expectedTextMessage);
Message message1 = consumer1.receive(1000L);
Message message2 = consumer2.receive(1000L);
Assert.assertEquals(testMessage, ((TextMessage) message1).getText());
Assert.assertEquals(testMessage, ((TextMessage) message2).getText());
// Wait till all traces are recorded (consumer traces are recorded from another thread)
awaitAndVerifyTraceCount(9, 5000L);
// trace count : 1
verifyProducerSendEvent(testTopic);
// trace count : 4
verifyConsumerPullEvent(testTopic, consumer1, expectedTextMessage);
// trace count : 4
verifyConsumerPullEvent(testTopic, consumer2, expectedTextMessage);
}
Aggregations