Tabnine Logo
TextMessage.setText
Code IndexAdd Tabnine to your IDE (free)

How to use
setText
method
in
javax.jms.TextMessage

Best Java code snippets using javax.jms.TextMessage.setText (Showing top 20 results out of 738)

Refine searchRefine arrow

  • Session.createTextMessage
  • MessageProducer.send
  • TextMessage.getText
origin: spring-projects/spring-integration

@SuppressWarnings("resource")
@Test
public void nonSiProducer_siConsumer_sync_withReturn() throws Exception {
  ActiveMqTestUtils.prepare();
  ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("Exception-nonSiProducer-siConsumer.xml", ExceptionHandlingSiConsumerTests.class);
  JmsTemplate jmsTemplate = new JmsTemplate(applicationContext.getBean("jmsConnectionFactory", ConnectionFactory.class));
  Destination request = applicationContext.getBean("requestQueueA", Destination.class);
  final Destination reply = applicationContext.getBean("replyQueueA", Destination.class);
  jmsTemplate.send(request, (MessageCreator) session -> {
    TextMessage message = session.createTextMessage();
    message.setText("echoChannel");
    message.setJMSReplyTo(reply);
    return message;
  });
  Message message = jmsTemplate.receive(reply);
  assertNotNull(message);
  applicationContext.close();
}
origin: spring-projects/spring-integration

@SuppressWarnings("resource")
@Test
public void nonSiProducer_siConsumer_sync_withReturnNoException() throws Exception {
  ActiveMqTestUtils.prepare();
  ConfigurableApplicationContext applicationContext = new ClassPathXmlApplicationContext("Exception-nonSiProducer-siConsumer.xml", ExceptionHandlingSiConsumerTests.class);
  JmsTemplate jmsTemplate = new JmsTemplate(applicationContext.getBean("jmsConnectionFactory", ConnectionFactory.class));
  Destination request = applicationContext.getBean("requestQueueB", Destination.class);
  final Destination reply = applicationContext.getBean("replyQueueB", Destination.class);
  jmsTemplate.send(request, (MessageCreator) session -> {
    TextMessage message = session.createTextMessage();
    message.setText("echoWithExceptionChannel");
    message.setJMSReplyTo(reply);
    return message;
  });
  Message message = jmsTemplate.receive(reply);
  assertNotNull(message);
  assertEquals("echoWithException", ((TextMessage) message).getText());
  applicationContext.close();
}
origin: spring-projects/spring-integration

String requestPayload = (String) extractPayload(message);
try {
  TextMessage replyMessage = session.createTextMessage();
  replyMessage.setText(requestPayload);
  replyMessage.setJMSCorrelationID(message.getJMSCorrelationID());
  MessageProducer producer = session.createProducer(replyDestination);
  producer.send(replyMessage);
origin: stackoverflow.com

myConnFactory = new com.sun.messaging.ConnectionFactory();
 Connection myConn = myConnFactory.createConnection();
 //Create a session within the connection.
 Session mySess = myConn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 myQueue = new com.sun.messaging.Queue("world");
 //Create a message producer.
 MessageProducer myMsgProducer = mySess.createProducer(myQueue);
 //Create a message consumer. (Use if going to read from the queue)
 MessageConsumer myMsgConsumer = mySess.createConsumer(myQueue);
 //Start the Connection
 myConn.start();
 //Create and send a message to the queue.
 TextMessage myTextMsg = mySess.createTextMessage();
 myTextMsg.setText("Hello World");
 System.out.println("Sending Message: " + myTextMsg.getText());
 myMsgProducer.send(myTextMsg);
 // The rest of the code is for reading from a queue - optional
 //Receive a message from the queue. 
 Message msg = myMsgConsumer.receive();
 //Retreive the contents of the message.
 if (msg instanceof TextMessage) {
   TextMessage txtMsg = (TextMessage) msg;
   System.out.println("Read Message: " + txtMsg.getText());
 }
origin: stackoverflow.com

 public DirectJMSRemotingClient() throws JMSException {
  factory = new ActiveMQConnectionFactory(brokerURL);
  connection = factory.createConnection();
  connection.start();
  session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
  Destination destination = session.createQueue("queueName");
  producer = session.createProducer(destination);
}

public void sendMessage() throws JMSException {

  TextMessage myTextMsg = session.createTextMessage();

  myTextMsg.setText("Hello World");
  System.out.println("Sending Message: " + myTextMsg.getText());
  producer.send(myTextMsg);
}

public static void main(String[] args) throws Exception {
  DirectJMSRemotingClient client = new DirectJMSRemotingClient();
  client.sendMessage();
}
origin: apache/activemq-artemis

@Test
public void testClearProperties() throws Exception {
 ((TextMessage) message).setText("something");
 queueProd.send(message);
 TextMessage rm = (TextMessage) queueCons.receive();
 rm.clearProperties();
 ProxyAssertSupport.assertEquals("something", rm.getText());
}
origin: stackoverflow.com

 try {
  ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory("tcp://localhost:61616");
  Connection conn = factory.createConnection(user, password);
  Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
  MessageProducer producer = session.createProducer("test");
  MessageConsumer consumer = session.createConsumer("test");
  consumer.setMessageListener(this); // class that implements MessageListener
  conn.start();
  TextMessage message = new ActiveMQTextMessage();
  message.setText("TestMessage");
  producer.send(message);
} catch (JMSException e) {
  // somethings very wrong
}
origin: spring-projects/spring-integration

TextMessage replyMessage = session.createTextMessage();
replyMessage.setText(requestPayload);
replyMessage.setJMSCorrelationID(message.getJMSMessageID());
MessageProducer producer = session.createProducer(replyTo);
producer.send(replyMessage);
origin: apache/activemq-artemis

@Test
public void testCreateTextMessageNull() throws Exception {
 conn = createConnection();
 Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 MessageProducer prod = session.createProducer(queue1);
 prod.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
 TextMessage m = session.createTextMessage();
 m.setText("message one");
 prod.send(m);
 conn.close();
 conn = createConnection();
 session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 MessageConsumer cons = session.createConsumer(queue1);
 conn.start();
 TextMessage rm = (TextMessage) cons.receive();
 ProxyAssertSupport.assertEquals("message one", rm.getText());
}
origin: spring-projects/spring-integration

@Test(expected = MessageTimeoutException.class)
public void messageCorrelationBasedOnRequestMessageIdOptimized() throws Exception {
  ActiveMqTestUtils.prepare();
  ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("producer-cached-consumers.xml", this.getClass());
  try {
    RequestReplyExchanger gateway = context.getBean("standardMessageIdCopyingConsumerWithOptimization", RequestReplyExchanger.class);
    CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
    final JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    final Destination requestDestination = context.getBean("siOutQueueOptimizedA", Destination.class);
    final Destination replyDestination = context.getBean("siInQueueOptimizedA", Destination.class);
    new Thread(() -> {
      final Message requestMessage = jmsTemplate.receive(requestDestination);
      jmsTemplate.send(replyDestination, (MessageCreator) session -> {
        TextMessage message = session.createTextMessage();
        message.setText("bar");
        message.setJMSCorrelationID(requestMessage.getJMSMessageID());
        return message;
      });
    }).start();
    gateway.exchange(new GenericMessage<String>("foo"));
  }
  finally {
    context.close();
  }
}
origin: de.taimos/dvalin-interconnect-core

/**
 * @param txt the message to encrypt
 * @throws JMSException    on JMS errors
 * @throws CryptoException on crypto errors
 */
public static void secureMessage(final TextMessage txt) throws JMSException, CryptoException {
  final String cryptedText = MessageCryptoUtil.crypt(txt.getText());
  txt.setText(cryptedText);
  txt.setStringProperty(MessageCryptoUtil.SIGNATURE_HEADER, MessageCryptoUtil.sign(cryptedText));
}
origin: fi.vm.sade.log/log-client

  @Override
  public Message createMessage(Session session) throws JMSException {
    TextMessage message = session.createTextMessage();
    message.setText(encode(event));
    log.debug("  sending log message - text={}", message.getText());
    return message;
  }
});
origin: de.dfki.cos.basys.platform.runtime/de.dfki.cos.basys.platform.runtime.gateway

  @Override
  public void handleMessage(Channel channel, String msg) {
    try {
      TextMessage outMsg = session.createTextMessage();
      outMsg.setText(msg);
      sender.send(outMsg);
    } catch (JMSException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
});
origin: apache/activemq-artemis

@Test
public void testTextMessage() throws Exception {
 TextMessage m = queueProducerSession.createTextMessage();
 m.setText(myString);
 queueProducer.send(m);
 ProxyAssertSupport.assertEquals(myString, m2.getText());
 m = queueProducerSession.createTextMessage(myString);
 queueProducer.send(m);
 ProxyAssertSupport.assertEquals(myString, m2.getText());
   m2.setText("Should be read-only");
   ProxyAssertSupport.fail();
 } catch (MessageNotWriteableException e) {
 ProxyAssertSupport.assertNull(m2.getText());
 m2.setText("Now it is read-write");
origin: spring-projects/spring-integration

@Test(expected = MessageTimeoutException.class)
public void messageCorrelationBasedOnRequestCorrelationIdNonOptimized() throws Exception {
  ActiveMqTestUtils.prepare();
  ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("producer-cached-consumers.xml", this.getClass());
  try {
    RequestReplyExchanger gateway = context.getBean("correlationPropagatingConsumerWithoutOptimization", RequestReplyExchanger.class);
    CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
    final JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    final Destination requestDestination = context.getBean("siOutQueueNonOptimizedD", Destination.class);
    final Destination replyDestination = context.getBean("siInQueueNonOptimizedD", Destination.class);
    new Thread(() -> {
      final Message requestMessage = jmsTemplate.receive(requestDestination);
      jmsTemplate.send(replyDestination, (MessageCreator) session -> {
        TextMessage message = session.createTextMessage();
        message.setText("bar");
        message.setJMSCorrelationID(requestMessage.getJMSCorrelationID());
        return message;
      });
    }).start();
    gateway.exchange(new GenericMessage<String>("foo"));
  }
  finally {
    context.close();
  }
}
origin: objectweb-joramtests/joramtests

/**
* Test that the <code>Message.clearProperties()</code> method does not clear the
* value of the Message's body.
*/
public void testClearProperties_2()
{
 try
 {
   TextMessage message = senderSession.createTextMessage();
   message.setText("foo");
   message.clearProperties();
   Assert.assertEquals("sec. 3.5.7 Clearing a message's  property entries does not clear the value of its body.\n",
             "foo",
             message.getText());
 }
 catch (JMSException e)
 {
   fail(e);
 }
}
origin: Talend/tesb-rt-se

private void postOneWayBook(Session session, Destination destination, Book book) 
  throws Exception {
  MessageProducer producer = session.createProducer(destination);
  
  TextMessage message = session.createTextMessage();
  message.setText(writeBook(book));
  producer.send(message);
  producer.close();
}

origin: apache/activemq-artemis

@Test
public void testSendReceiveNullBody() throws Exception {
 conn = cf.createConnection();
 Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
 MessageProducer prod = sess.createProducer(queue);
 conn.start();
 MessageConsumer cons = sess.createConsumer(queue);
 TextMessage msg1 = sess.createTextMessage(null);
 prod.send(msg1);
 TextMessage received1 = (TextMessage) cons.receive(1000);
 Assert.assertNotNull(received1);
 Assert.assertNull(received1.getText());
 TextMessage msg2 = sess.createTextMessage();
 msg2.setText(null);
 prod.send(msg2);
 TextMessage received2 = (TextMessage) cons.receive(1000);
 Assert.assertNotNull(received2);
 Assert.assertNull(received2.getText());
 TextMessage msg3 = sess.createTextMessage();
 prod.send(msg3);
 TextMessage received3 = (TextMessage) cons.receive(1000);
 Assert.assertNotNull(received3);
 Assert.assertNull(received3.getText());
}
origin: spring-projects/spring-integration

@Test
public void messageCorrelationBasedOnRequestCorrelationIdOptimized() throws Exception {
  ActiveMqTestUtils.prepare();
  ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("producer-cached-consumers.xml", this.getClass());
  try {
    RequestReplyExchanger gateway = context.getBean("correlationPropagatingConsumerWithOptimization", RequestReplyExchanger.class);
    CachingConnectionFactory connectionFactory = context.getBean(CachingConnectionFactory.class);
    final JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
    final Destination requestDestination = context.getBean("siOutQueueOptimizedC", Destination.class);
    final Destination replyDestination = context.getBean("siInQueueOptimizedC", Destination.class);
    new Thread(() -> {
      final Message requestMessage = jmsTemplate.receive(requestDestination);
      jmsTemplate.send(replyDestination, (MessageCreator) session -> {
        TextMessage message = session.createTextMessage();
        message.setText("bar");
        message.setJMSCorrelationID(requestMessage.getJMSCorrelationID());
        return message;
      });
    }).start();
    org.springframework.messaging.Message<?> siReplyMessage = gateway.exchange(new GenericMessage<String>("foo"));
    assertEquals("bar", siReplyMessage.getPayload());
  }
  finally {
    context.close();
  }
}
origin: pierre/meteo

/**
 * Processes an incoming command from a console and returning the text to
 * output
 */
public String processCommandText(String line) throws Exception {
  TextMessage request = new ActiveMQTextMessage();
  request.setText(line);
  TextMessage response = new ActiveMQTextMessage();
  getHandler().processCommand(request, response);
  return response.getText();
}
javax.jmsTextMessagesetText

Javadoc

Sets the string containing this message's data.

Popular methods of TextMessage

  • getText
    Gets the string containing this message's data. The default value is null.
  • setStringProperty
  • setJMSCorrelationID
  • setIntProperty
  • setLongProperty
  • getStringProperty
  • setBooleanProperty
  • setJMSReplyTo
  • getJMSCorrelationID
  • getJMSMessageID
  • getJMSReplyTo
  • setDoubleProperty
  • getJMSReplyTo,
  • setDoubleProperty,
  • acknowledge,
  • setJMSType,
  • getJMSDeliveryMode,
  • setObjectProperty,
  • getIntProperty,
  • getJMSPriority,
  • clearBody

Popular in Java

  • Running tasks concurrently on multiple threads
  • getSharedPreferences (Context)
  • runOnUiThread (Activity)
  • getResourceAsStream (ClassLoader)
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • StringTokenizer (java.util)
    Breaks a string into tokens; new code should probably use String#split.> // Legacy code: StringTo
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JList (javax.swing)
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • Top 17 Free Sublime Text Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now