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

How to use
getStringProperty
method
in
javax.jms.TextMessage

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

origin: spring-projects/spring-framework

private void assertTextMessage(MessageCreator messageCreator) {
  try {
    TextMessage jmsMessage = createTextMessage(messageCreator);
    assertEquals("Wrong body message", "Hello", jmsMessage.getText());
    assertEquals("Invalid foo property", "bar", jmsMessage.getStringProperty("foo"));
  }
  catch (JMSException e) {
    throw new IllegalStateException("Wrong text message", e);
  }
}
origin: spring-projects/spring-framework

@Test
public void fromTextMessageAsMap() throws Exception {
  TextMessage textMessageMock = mock(TextMessage.class);
  Map<String, String> unmarshalled = Collections.singletonMap("foo", "bar");
  String text = "{\"foo\":\"bar\"}";
  given(textMessageMock.getStringProperty("__typeid__")).willReturn(HashMap.class.getName());
  given(textMessageMock.getText()).willReturn(text);
  Object result = converter.fromMessage(textMessageMock);
  assertEquals("Invalid result", result, unmarshalled);
}
origin: spring-projects/spring-framework

@Test
public void fromTextMessageAsObject() throws Exception {
  TextMessage textMessageMock = mock(TextMessage.class);
  Map<String, String> unmarshalled = Collections.singletonMap("foo", "bar");
  String text = "{\"foo\":\"bar\"}";
  given(textMessageMock.getStringProperty("__typeid__")).willReturn(Object.class.getName());
  given(textMessageMock.getText()).willReturn(text);
  Object result = converter.fromMessage(textMessageMock);
  assertEquals("Invalid result", result, unmarshalled);
}
origin: spring-projects/spring-framework

@Test
public void fromTextMessage() throws Exception {
  TextMessage textMessageMock = mock(TextMessage.class);
  MyBean unmarshalled = new MyBean("bar");
  String text = "{\"foo\":\"bar\"}";
  given(textMessageMock.getStringProperty("__typeid__")).willReturn(MyBean.class.getName());
  given(textMessageMock.getText()).willReturn(text);
  MyBean result = (MyBean)converter.fromMessage(textMessageMock);
  assertEquals("Invalid result", result, unmarshalled);
}
origin: spring-projects/spring-framework

@Test
public void fromTextMessageWithUnknownProperty() throws Exception {
  TextMessage textMessageMock = mock(TextMessage.class);
  MyBean unmarshalled = new MyBean("bar");
  String text = "{\"foo\":\"bar\", \"unknownProperty\":\"value\"}";
  given(textMessageMock.getStringProperty("__typeid__")).willReturn(MyBean.class.getName());
  given(textMessageMock.getText()).willReturn(text);
  MyBean result = (MyBean)converter.fromMessage(textMessageMock);
  assertEquals("Invalid result", result, unmarshalled);
}
origin: stackoverflow.com

 Queue destination = session.createQueue("your_q");

QueueBrowser browser = session.createBrowser(destination);

Enumeration<?> enum1 = browser.getEnumeration();

while(enum1.hasMoreElements())
{
  TextMessage msg = (TextMessage)enum1.nextElement();
  if(msg.getStringProperty("any_prop").equals("some_prop"))
  {
    MessageConsumer consumer = session.createConsumer(destination, "id='" +   msg.getStringProperty("id") + "'");
   consumer.receive(1000);
  }
}
origin: stackoverflow.com

 @Override
public void onMessage(Message message) {
  try {
    count++;
    TextMessage msg = (TextMessage) message;
    System.out.println("Message Received " + msg.getText());
    System.out.println("Message received from " + msg.getStringProperty("SentToNode"));
    //now you can send the message to that node

  } catch (JMSException e) {
    e.printStackTrace();
  }
}
origin: apache/activemq-artemis

private void receiveLVQ(ConnectionSupplier consumerConnectionSupplier, String queueName, String lastValueKey) throws JMSException {
 try (Connection connection = consumerConnectionSupplier.createConnection();
    Session session = connection.createSession();
    MessageConsumer consumer = session.createConsumer(session.createQueue(queueName))) {
   TextMessage msg = (TextMessage) consumer.receive(1000);
   assertNotNull(msg);
   assertEquals("KEY", msg.getStringProperty(lastValueKey));
   assertEquals("how are you", msg.getText());
 }
}
origin: apache/activemq-artemis

private void receiveLVQTombstone(ConnectionSupplier consumerConnectionSupplier, String queueName, String lastValueKey) throws JMSException {
 try (Connection connection = consumerConnectionSupplier.createConnection();
    Session session = connection.createSession();
    MessageConsumer consumer = session.createConsumer(session.createQueue(queueName))) {
   TextMessage msg = (TextMessage) consumer.receive(1000);
   assertNotNull(msg);
   assertEquals("KEY", msg.getStringProperty(lastValueKey));
   assertEquals("tombstone", msg.getText());
 }
}
origin: apache/activemq-artemis

private void receiveLVQ(ConnectionSupplier consumerConnectionSupplier, String queueName, String lastValueKey) throws JMSException {
 try (Connection consumerConnection = consumerConnectionSupplier.createConnection()) {
   Session consumerSession = consumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
   Queue consumerQueue = consumerSession.createQueue(queueName);
   MessageConsumer consumer = consumerSession.createConsumer(consumerQueue);
   TextMessage msg = (TextMessage) consumer.receive(1000);
   assertNotNull(msg);
   assertEquals("KEY", msg.getStringProperty(lastValueKey));
   assertEquals("how are you", msg.getText());
   consumer.close();
 }
}
origin: apache/activemq-artemis

@Test
public void testReceiveContentType() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 ClientStompFrame response = send(conn, getQueuePrefix() + getQueueName(), "text/plain", "Hello World");
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("text/plain", message.getStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_CONTENT_TYPE.toString()));
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithCustomHeadersAndHyphenatedSelector() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue, "hyphenated_props:b-ar = '123'");
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .addHeader("foo", "abc")
                .addHeader("b-ar", "123")
                .setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
 Assert.assertEquals("b-ar", "123", message.getStringProperty("b-ar"));
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .addHeader("foo", "abc")
                .addHeader("bar", "123")
                .setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
 Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader("foo", "abc")
                .addHeader("bar", "123")
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
 Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
}
origin: apache/activemq-artemis

@Test
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Subscribe.DESTINATION, getQueuePrefix() + getQueueName())
                .addHeader("foo", "abc")
                .addHeader("bar", "123")
                .setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 Assert.assertEquals("foo", "abc", message.getStringProperty("foo"));
 Assert.assertEquals("bar", "123", message.getStringProperty("bar"));
}
origin: apache/activemq-artemis

@Test
public void testJMSXGroupIdCanBeSet() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .addHeader("JMSXGroupID", "TEST")
                .setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // differ from StompConnect
 Assert.assertEquals("TEST", message.getStringProperty("JMSXGroupID"));
}
origin: apache/activemq-artemis

@Test
public void testJMSXGroupIdCanBeSet() throws Exception {
 final String jmsxGroupID = "JMSXGroupID";
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND)
                .addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName())
                .addHeader("JMSXGroupID", jmsxGroupID)
                .setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // differ from StompConnect
 Assert.assertEquals(jmsxGroupID, message.getStringProperty("JMSXGroupID"));
}
origin: apache/activemq-artemis

@Test
public void testJMSXGroupIdCanBeSet() throws Exception {
 MessageConsumer consumer = session.createConsumer(queue);
 conn.connect(defUser, defPass);
 ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND);
 frame.addHeader(Stomp.Headers.Subscribe.DESTINATION, getQueuePrefix() + getQueueName());
 frame.addHeader("JMSXGroupID", "TEST");
 frame.setBody("Hello World");
 conn.sendFrame(frame);
 TextMessage message = (TextMessage) consumer.receive(1000);
 Assert.assertNotNull(message);
 Assert.assertEquals("Hello World", message.getText());
 // differ from StompConnect
 Assert.assertEquals("TEST", message.getStringProperty("JMSXGroupID"));
}
origin: apache/activemq-artemis

/**
* Test that the <code>TextMessage.clearBody()</code> method does not clear the
* message properties.
*/
@Test
public void testClearBody_2() {
 try {
   TextMessage message = senderSession.createTextMessage();
   message.setStringProperty("prop", "foo");
   message.clearBody();
   Assert.assertEquals("sec. 3.11.1 Clearing a message's body does not clear its property entries.\n", "foo", message.getStringProperty("prop"));
 } catch (JMSException e) {
   fail(e);
 }
}
origin: apache/activemq-artemis

  /**
  * Test that the <code>Message.clearProperties()</code> method deletes all the
  * properties of the Message.
  */
  @Test
  public void testClearProperties_1() {
   try {
     TextMessage message = senderSession.createTextMessage();
     message.setStringProperty("prop", "foo");
     message.clearProperties();
     Assert.assertEquals("sec. 3.5.7 A message's properties are deleted by the clearProperties method.\n", null, message.getStringProperty("prop"));
   } catch (JMSException e) {
     fail(e);
   }
  }
}
javax.jmsTextMessagegetStringProperty

Popular methods of TextMessage

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

Popular in Java

  • Reading from database using SQL prepared statement
  • onRequestPermissionsResult (Fragment)
  • putExtra (Intent)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • FlowLayout (java.awt)
    A flow layout arranges components in a left-to-right flow, much like lines of text in a paragraph. F
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • JPanel (javax.swing)
  • Best plugins for Eclipse
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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