本文整理匯總了Java中javax.jms.TextMessage.setText方法的典型用法代碼示例。如果您正苦於以下問題:Java TextMessage.setText方法的具體用法?Java TextMessage.setText怎麽用?Java TextMessage.setText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.jms.TextMessage
的用法示例。
在下文中一共展示了TextMessage.setText方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: putTopic
import javax.jms.TextMessage; //導入方法依賴的package包/類
private void putTopic(List<String> events) throws Exception {
ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME,
PASSWORD, BROKER_BIND_URL);
Connection connection = factory.createConnection();
connection.start();
Session session = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createTopic(DESTINATION_NAME);
MessageProducer producer = session.createProducer(destination);
for (String event : events) {
TextMessage message = session.createTextMessage();
message.setText(event);
producer.send(message);
}
session.commit();
session.close();
connection.close();
}
示例2: testReception
import javax.jms.TextMessage; //導入方法依賴的package包/類
private void testReception(
final TestClass i,
final Destination destination, final ThrowingConsumer<Destination> destinationCheck
) throws Exception {
final Connection connection = i.connectionFactory.createConnection();
assertNotNull(connection);
final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
assertNotNull(session);
final MessageProducer producer = session.createProducer(destination);
assertNotNull(producer);
final TextMessage message = session.createTextMessage();
assertNotNull(message);
message.setText("I am IronMan");
producer.send(message);
final List<ReceivedJmsMessage> messages = i.testQueue.drainReceivedMessages();
assertEquals(1, messages.size());
final ReceivedJmsMessage receivedMessage = messages.get(0);
destinationCheck.accept(receivedMessage.getDestination());
assertTrue(receivedMessage.getJmsMessage() instanceof TextMessage);
final TextMessage receivedTextMessage = (TextMessage) receivedMessage.getJmsMessage();
assertEquals("I am IronMan", receivedTextMessage.getText());
}
示例3: publish
import javax.jms.TextMessage; //導入方法依賴的package包/類
/**
* @param topicConnection
* @param chatTopic
* @param userId
* @throws JMSException
* @throws IOException
*/
void publish(TopicConnection topicConnection, Topic chatTopic, String userId)
throws JMSException, IOException {
TopicSession tsession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
TopicPublisher topicPublisher = tsession.createPublisher(chatTopic);
topicConnection.start();
BufferedReader reader = new BufferedReader(new InputStreamReader(
System.in));
while (true) {
String msgToSend = reader.readLine();
if (msgToSend.equalsIgnoreCase("exit")) {
topicConnection.close();
System.exit(0);
} else {
TextMessage msg = (TextMessage) tsession.createTextMessage();
msg.setText("\n["+userId + " : " + msgToSend+"]");
topicPublisher.publish(msg);
}
}
}
示例4: putQueue
import javax.jms.TextMessage; //導入方法依賴的package包/類
private void putQueue(List<String> events) throws Exception {
ConnectionFactory factory = new ActiveMQConnectionFactory(USERNAME,
PASSWORD, BROKER_BIND_URL);
Connection connection = factory.createConnection();
connection.start();
Session session = connection.createSession(true,
Session.AUTO_ACKNOWLEDGE);
Destination destination = session.createQueue(DESTINATION_NAME);
MessageProducer producer = session.createProducer(destination);
for (String event : events) {
TextMessage message = session.createTextMessage();
message.setText(event);
producer.send(message);
}
session.commit();
session.close();
connection.close();
}
示例5: verstuurBijhoudingsNotificatie
import javax.jms.TextMessage; //導入方法依賴的package包/類
@Override
public void verstuurBijhoudingsNotificatie(final BijhoudingsplanNotificatieBericht notificatieBericht) {
try {
final MessageCreator messageCreator = session -> {
final TextMessage message = session.createTextMessage();
// Header voor message group mechanisme van ActiveMq
message.setStringProperty("JMSXGroupID", String.valueOf(notificatieBericht.getOntvangendePartijCode()));
message.setText(serialiseerderBijhoudingsplan.serialiseerNaarString(notificatieBericht));
return message;
};
bijhoudingsplanJmsTemplate.send(messageCreator);
} catch (final JmsException e) {
LOGGER.error("Het publiceren van het verwerk BijhoudingsplanBericht is mislukt ivm een JMS exceptie.", e);
throw e;
}
}
示例6: createTextMessage
import javax.jms.TextMessage; //導入方法依賴的package包/類
public TextMessage createTextMessage(String text) throws JMSException {
TextMessage textMessage = new ProxyTextMessage();
textMessage.setText(text);
return textMessage;
}