use of javax.jms.TextMessage in project wildfly by wildfly.
the class ConfiguredResourceAdapterNameTestCase method testMDBWithOverriddenResourceAdapterName.
@Test
public void testMDBWithOverriddenResourceAdapterName() throws Exception {
final String goodMorning = "Hello World";
// send as TextMessage
this.jmsUtil.sendTextMessage(goodMorning, this.queue, this.replyQueue);
// wait for an reply
final Message reply = this.jmsUtil.receiveMessage(replyQueue, 5000);
// test the reply
final TextMessage textMessage = (TextMessage) reply;
Assert.assertNotNull(textMessage);
Assert.assertEquals("Unexpected reply message on reply queue: " + this.replyQueue, ConfiguredResourceAdapterNameMDB.REPLY, textMessage.getText());
}
use of javax.jms.TextMessage in project wildfly by wildfly.
the class MessagingEjb method sendTextMessage.
public void sendTextMessage(final String msg) throws JMSException {
final TextMessage message = session.createTextMessage(msg);
this.sendMessage(message, queue, replyQueue);
}
use of javax.jms.TextMessage in project wildfly by wildfly.
the class SetMessageDrivenContextInvocationTestCase method testSetMessageDrivenContext.
/**
* Test that the {@link javax.ejb.MessageDrivenBean#setMessageDrivenContext(javax.ejb.MessageDrivenContext)}
* was invoked
*
* @throws Exception
*/
@Test
public void testSetMessageDrivenContext() throws Exception {
this.jmsUtil.sendTextMessage("hello world", this.queue, this.replyQueue);
final Message reply = this.jmsUtil.receiveMessage(replyQueue, 5000);
Assert.assertNotNull("Reply message was null on reply queue: " + this.replyQueue, reply);
final TextMessage textMessage = (TextMessage) reply;
Assert.assertEquals("setMessageDrivenContext method was *not* invoked on MDB", SimpleMDB.SUCCESS_REPLY, textMessage.getText());
}
use of javax.jms.TextMessage in project wildfly by wildfly.
the class MDBProxyBean method trigger.
@Override
public void trigger() throws Exception {
final String goodMorning = "Good morning";
// send as ObjectMessage
// this.jmsUtil = (JMSMessagingUtil) getInitialContext().lookup(getEJBJNDIBinding());
this.jmsUtil.sendTextMessage(goodMorning, this.queue, this.replyQueue);
// wait for an reply
final Message reply = this.jmsUtil.receiveMessage(replyQueue, 5000);
// test the reply
final TextMessage textMessage = (TextMessage) reply;
Assert.assertEquals("Unexpected reply message on reply queue: " + this.replyQueue, CdiIntegrationMDB.REPLY, textMessage.getText());
}
use of javax.jms.TextMessage in project wildfly by wildfly.
the class EJB2xMDB method onMessage.
@Override
public void onMessage(Message message) {
logger.trace("Received message " + message + " in MDB " + this.getClass().getName());
try {
if (message.getStringProperty("MessageFormat") != null)
logger.trace("MessageFormat property = " + message.getStringProperty("MessageFormat"));
Destination replyTo = message.getJMSReplyTo();
if (replyTo == null) {
try {
logger.trace("mdbContext = " + mdbContext);
replyTo = (Destination) mdbContext.lookup("jms/replyQueue");
} catch (Throwable e) {
logger.warn(e);
}
} else {
logger.trace("Using replyTo from message JMSReplyTo: " + replyTo);
}
if (replyTo == null) {
throw new EJBException("no replyTo Destination");
}
final TextMessage tm = (TextMessage) message;
final String reply = tm.getText() + "processed by: " + hashCode();
try (JMSContext context = cf.createContext()) {
context.createProducer().setJMSCorrelationID(message.getJMSMessageID()).send(replyTo, reply);
}
} catch (Exception e) {
logger.error(e);
throw new EJBException(e);
}
}
Aggregations