本文整理汇总了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;
}