本文整理匯總了Java中javax.jms.TextMessage.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextMessage.getText方法的具體用法?Java TextMessage.getText怎麽用?Java TextMessage.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.TextMessage
的用法示例。
在下文中一共展示了TextMessage.getText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void onMessage(Message message) {
try {
if (message instanceof BytesMessage) {
BytesMessage bytesMessage = (BytesMessage) message;
byte[] data = new byte[(int) bytesMessage.getBodyLength()];
bytesMessage.readBytes(data);
LOG.info("Message received {}", new String(data));
} else if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String text = textMessage.getText();
LOG.info("Message received {}", text);
}
} catch (JMSException jmsEx) {
jmsEx.printStackTrace();
}
}
示例2: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
/**
* Implementation of <code>MessageListener</code>.
*/
public void onMessage(Message message) {
try {
int messageCount = message.getIntProperty(JmsMessageProducer.MESSAGE_COUNT);
if (message instanceof TextMessage) {
TextMessage tm = (TextMessage)message;
String msg = tm.getText();
System.out.println("Processed message '{}'. value={}"+ msg+ messageCount);
counter.incrementAndGet();
}
} catch (JMSException e) {
e.printStackTrace();
}
}
示例3: handleMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
private void handleMessage(MessageHandler handler, Message message, Session session) {
if (! (message instanceof TextMessage)) {
return;
}
TextMessage textMessage = (TextMessage) message;
String text = null;
String requestId = UUID.randomUUID().toString();
try {
text = textMessage.getText();
if (StringUtils.isNotEmpty(message.getJMSCorrelationID())) {
requestId = message.getJMSCorrelationID();
}
MDC.put(X_OBOS_REQUEST_ID, requestId);
log.info("Received message '{}'", text);
handler.handle(new ObjectMapper().readTree(text));
} catch (Exception e) {
log.error("Failed to process message", e);
try {
TextMessage errorMessage = session.createTextMessage(text);
errorMessage.setJMSCorrelationID(requestId);
Queue queue = session.createQueue(queueError);
MessageProducer errorProducer = session.createProducer(queue);
errorProducer.send(errorMessage);
} catch (JMSException jmse) {
log.error("Failed to create error message", jmse);
}
} finally {
MDC.remove(X_OBOS_REQUEST_ID);
}
}
示例4: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void onMessage(final Message message) {
BrpNu.set(DatumUtil.nuAlsZonedDateTime());
try {
LOGGER.debug("onMessage");
LOGGER.info("Geen personen vallen binnen de selectie Sv11 wordt uitgestuurd.");
final TextMessage textMessage = (TextMessage) message;
final String text = textMessage.getText();
final MaakSelectieResultaatTaak
maakSelectieResultaatTaak =
JSON_STRING_SERIALISEERDER.deserialiseerVanuitString(text, MaakSelectieResultaatTaak.class);
selectieGeenResultaatGbaBerichtWriter.verstuurSv11Bericht(maakSelectieResultaatTaak);
} catch (JMSException e) {
LOGGER.error("error on message", e);
}
}
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:17,代碼來源:MaakSelectieGeenResultaatNetwerkTaakQueueMessageListener.java
示例5: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void onMessage(Message msg) {
if (msg instanceof TextMessage) {
TextMessage textMessage = (TextMessage) msg;
String text = "";
try {
text = textMessage.getText();
} catch (JMSException e) {
logger.error(e.getMessage());
e.printStackTrace();
}
System.out.println("Received: " + text);
} else {
System.out.println("Received: " + msg);
}
}
示例6: startConsumer
import javax.jms.TextMessage; //導入方法依賴的package包/類
private void startConsumer() {
try {
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination;
if ("topic".equalsIgnoreCase(destinationType)) {
destination = session.createTopic(destinationName);
} else {
destination = session.createQueue(destinationName);
}
consumer = session.createConsumer(destination);
isStarted.compareAndSet(false, true);
while (true) {
Message message = consumer.receive();
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String text = textMessage.getText();
if (isRecording.get()) {
addData(message, text);
}
counter.incrementAndGet();
}
}
} catch (Exception e) {
//e.printStackTrace();
} finally {
terminate();
}
}
示例7: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void onMessage(final Message message) {
BrpNu.set(DatumUtil.nuAlsZonedDateTime());
try {
LOGGER.debug("onMessage");
final TextMessage textMessage = (TextMessage) message;
final String text = textMessage.getText();
final MaakSelectieResultaatTaak
maakSelectieResultaatTaak =
JSON_STRING_SERIALISEERDER.deserialiseerVanuitString(text, MaakSelectieResultaatTaak.class);
final SoortSelectie soortSelectie = maakSelectieResultaatTaak.getSoortSelectie();
if (soortSelectie == SoortSelectie.STANDAARD_SELECTIE) {
maakSelectieResultaatTaakVerwerkerServiceImpl.verwerk(maakSelectieResultaatTaak);
} else if (soortSelectie == SoortSelectie.SELECTIE_MET_PLAATSING_AFNEMERINDICATIE
|| soortSelectie == SoortSelectie.SELECTIE_MET_VERWIJDERING_AFNEMERINDICATIE) {
afnemerindicatieMaakSelectieResultaatTaakVerwerkerServiceImpl.verwerk(maakSelectieResultaatTaak);
}
} catch (JMSException e) {
LOGGER.error("error on message", e);
}
}
示例8: main
import javax.jms.TextMessage; //導入方法依賴的package包/類
public static void main(String[] args) {
try {
// Create a ConnectionFactory
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://Toshiba:61616");
// Create a Connection
Connection connection = connectionFactory.createConnection();
connection.start();
// Create a Session
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the destination (Topic or Queue)
Destination destination = session.createQueue("HELLOWORLD.TESTQ");
// Create a MessageConsumer from the Session to the Topic or Queue
MessageConsumer consumer = session.createConsumer(destination);
// Wait for a message
Message message = consumer.receive(1000);
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String text = textMessage.getText();
System.out.println("Received: " + text);
} else {
System.out.println("Received: " + message);
}
consumer.close();
session.close();
connection.close();
} catch (Exception e) {
e.printStackTrace();
}
}
示例9: run
import javax.jms.TextMessage; //導入方法依賴的package包/類
public void run() {
try {
// Create a ConnectionFactory
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://Toshiba:61616");
// Create a Connection
Connection connection = connectionFactory.createConnection();
connection.start();
connection.setExceptionListener(this);
// Create a Session
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// Create the destination (Topic or Queue)
Destination destination = session.createQueue("HELLOWORLD.TESTQ");
// Create a MessageConsumer from the Session to the Topic or Queue
MessageConsumer consumer = session.createConsumer(destination);
// Wait for a message
Message message = consumer.receive(1000);
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String text = textMessage.getText();
System.out.println("Received: " + text);
} else {
System.out.println("Received: " + message);
}
consumer.close();
session.close();
connection.close();
} catch (Exception e) {
System.out.println("Caught: " + e);
e.printStackTrace();
}
}
示例10: requeueFailedMessages
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void requeueFailedMessages() {
try {
ActiveMQConnection connection = ActiveMqUtils.openConnection(user, password, url);
Session session = ActiveMqUtils.startSession(connection);
int count = getQueueSize(session, queueError);
if (count < 1) {
return;
}
log.info("Requeuing {} failed messages...", count);
Queue queueErr = session.createQueue(queueError);
MessageConsumer consumer = session.createConsumer(queueErr);
Queue queueRetry = session.createQueue(queueInput);
MessageProducer producer = session.createProducer(queueRetry);
for (int consumed = 0; consumed < count; consumed++) {
TextMessage message = (TextMessage) consumer.receive(REQUEUE_TIMEOUT);
if (message == null) {
continue;
}
String text = message.getText();
String requestId = message.getJMSCorrelationID();
log.info("Requeuing message '{}'", text);
try {
TextMessage newMessage = session.createTextMessage(text);
newMessage.setJMSCorrelationID(requestId);
producer.send(newMessage);
} catch (Exception e) {
log.error("Failed to requeue message", e);
}
message.acknowledge();
session.commit();
}
producer.close();
consumer.close();
} catch (JMSException ex) {
throw new MessageQueueException("Failed to requeue failed messages", ex);
}
}
示例11: checkActiveMQJMSProtocol
import javax.jms.TextMessage; //導入方法依賴的package包/類
public String checkActiveMQJMSProtocol(String messageAsString,
String url) throws JMSException {
ActiveMQConnectionFactory activeMQConnectionFactory =
new ActiveMQConnectionFactory(String.format("tcp://%s", url));
CachingConnectionFactory connectionFactory = new CachingConnectionFactory(activeMQConnectionFactory);
JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
Destination destination = new ActiveMQQueue("myQueue");
jmsTemplate.setDefaultDestination(destination);
jmsTemplate.send(destination, t -> {
TextMessage message = t.createTextMessage(messageAsString);
return message;
});
TextMessage receivedMessage = (TextMessage) jmsTemplate.receive(destination);
return receivedMessage.getText();
}
示例12: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void onMessage(final Message message) {
BrpNu.set(DatumUtil.nuAlsZonedDateTime());
try {
LOGGER.debug("onMessage");
final TextMessage textMessage = (TextMessage) message;
final String text = textMessage.getText();
final SelectieFragmentSchrijfBericht
selectieSchrijfTaak =
JSON_STRING_SERIALISEERDER.deserialiseerVanuitString(text, SelectieFragmentSchrijfBericht.class);
selectieFragmentSchrijfTaakVerwerkerService.verwerk(selectieSchrijfTaak);
} catch (JMSException e) {
LOGGER.error("error on message", e);
}
}
示例13: waitForNextMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
public String waitForNextMessage() {
try {
TextMessage tm = (TextMessage) consumer.receive();
return tm.getText();
} catch (JMSException e) {
throw new RuntimeException(e);
}
}
示例14: onMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void onMessage(Message message) {
try {
TextMessage tm = (TextMessage) message;
String json = tm.getText();
logger.info("*** received message: {}", json);
Shipment shipment = JsonUtils.fromJson(json, Shipment.class);
shipments.add(shipment);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例15: startConsumer
import javax.jms.TextMessage; //導入方法依賴的package包/類
public void startConsumer() {
try {
connection = connectionFactory.createConnection();
connection.start();
session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
Destination destination = null;
if ("topic".equalsIgnoreCase(destinationType)) {
destination = session.createTopic(destinationName);
}
else {
destination = session.createQueue(destinationName);
}
consumer = session.createConsumer(destination);
isStarted.compareAndSet(false, true);
while (true) {
Message message = consumer.receive();
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
String text = textMessage.getText();
//System.out.println("Received: " + text);
counter.incrementAndGet();
if (isRecording.get()) {
addData(message, text);
}
}
}
} catch (Exception e) {
//e.printStackTrace();
} finally {
terminate();
}
}