本文整理了Java中javax.jms.Message.getBody()
方法的一些代码示例,展示了Message.getBody()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getBody()
方法的具体详情如下:
包路径:javax.jms.Message
类名称:Message
方法名:getBody
[英]Returns the message body as an object of the specified type. This method may be called on any type of message except for StreamMessage. The message body must be capable of being assigned to the specified type. This means that the specified class or interface must be either the same as, or a superclass or superinterface of, the class of the message body. If the message has no body then any type may be specified and null is returned.
[中]将消息正文作为指定类型的对象返回。除StreamMessage外,此方法可在任何类型的消息上调用。消息正文必须能够分配给指定的类型。这意味着指定的类或接口必须与消息体的类相同,或者是该类的超类或超接口。如果消息没有正文,则可以指定任何类型并返回null。
代码示例来源:origin: wildfly/wildfly
@Override
public <T> T receiveBody(Class<T> c) {
try {
Message message = consumer.receive();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public <T> T receiveBody(Class<T> c, long timeout) {
try {
Message message = consumer.receive(timeout);
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: wildfly/wildfly
@Override
public <T> T receiveBodyNoWait(Class<T> c) {
try {
Message message = consumer.receiveNoWait();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: pentaho/pentaho-kettle
/**
* Will receive messages from consumer. If timeout is hit, consumer.receive(timeout)
* will return null, and the observable will be completed.
*/
private void receiveLoop() {
Message message;
try {
while ( !closed.get() && ( message = consumer.receive( receiverTimeout ) ) != null ) {
streamStep.logDebug( message.toString() );
acceptRows( singletonList( Arrays.asList( message.getBody( Object.class ), jmsDelegate.destinationName ) ) );
}
} catch ( JMSRuntimeException | JMSException jmsException ) {
error( jmsException );
} finally {
super.close();
if ( !closed.get() ) {
close();
streamStep.logBasic( getString( PKG, "JmsStreamSource.HitReceiveTimeout" ) );
}
}
}
代码示例来源:origin: agoncal/agoncal-book-javaee7
public void onMessage(Message message) {
try {
System.out.println("Message received: " + message.getBody(String.class));
} catch (JMSException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: agoncal/agoncal-book-javaee7
public void onMessage(Message message) {
try {
System.out.println("Async Message received: " + message.getBody(String.class));
} catch (JMSException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: agoncal/agoncal-book-javaee7
public void onMessage(Message message) {
try {
System.out.println("Message received: " + message.getBody(String.class));
} catch (JMSException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T receiveBody(Class<T> c) {
try {
Message message = consumer.receive();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: agoncal/agoncal-book-javaee7
public void onMessage(Message message) {
try {
OrderDTO order = message.getBody(OrderDTO.class);
System.out.println("Expensive order received: " + order.toString());
} catch (JMSException e) {
e.printStackTrace();
}
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T receiveBody(Class<T> c) {
try {
Message message = consumer.receive();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: org.apache.activemq/artemis-jms-client-all
@Override
public <T> T receiveBody(Class<T> c) {
try {
Message message = consumer.receive();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T receiveBody(Class<T> c, long timeout) {
try {
Message message = consumer.receive(timeout);
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T receiveBody(Class<T> c, long timeout) {
try {
Message message = consumer.receive(timeout);
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: agoncal/agoncal-book-javaee7
public void onMessage(Message message) {
try {
System.out.println("Message received: " + message.getBody(String.class));
sendPrintingMessage();
} catch (JMSException e) {
e.printStackTrace();
}
}
代码示例来源:origin: org.apache.activemq/artemis-jms-client-all
@Override
public <T> T receiveBody(Class<T> c, long timeout) {
try {
Message message = consumer.receive(timeout);
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: org.jboss.eap/wildfly-client-all
@Override
public <T> T receiveBody(Class<T> c, long timeout) {
try {
Message message = consumer.receive(timeout);
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T getBody(Class<T> c) throws JMSException {
if (ActiveMQRALogger.LOGGER.isTraceEnabled()) {
ActiveMQRALogger.LOGGER.trace("getBody(" + c + ")");
}
return message.getBody(c);
}
代码示例来源:origin: org.apache.tomee/openejb-core
@Override
public <T> T receiveBody(final Class<T> c, final long timeout) {
try {
final Message message = wrap(consumer.receive(timeout));
context.setLastMessage(message);
return message == null ? null : message.getBody(c);
} catch (final JMSException e) {
throw toRuntimeException(e);
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T receiveBodyNoWait(Class<T> c) {
try {
Message message = consumer.receiveNoWait();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
代码示例来源:origin: apache/activemq-artemis
@Override
public <T> T receiveBodyNoWait(Class<T> c) {
try {
Message message = consumer.receiveNoWait();
context.setLastMessage(ActiveMQJMSConsumer.this, message);
return message == null ? null : message.getBody(c);
} catch (JMSException e) {
throw JmsExceptionUtils.convertToRuntimeException(e);
}
}
内容来源于网络,如有侵权,请联系作者删除!