当前位置: 首页>>代码示例>>Java>>正文


Java TextMessage.setText方法代码示例

本文整理汇总了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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestIntegrationActiveMQ.java

示例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());
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:24,代码来源:JavaMessagingTest.java

示例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);
		}
	}
}
 
开发者ID:Illusionist80,项目名称:SpringTutorial,代码行数:30,代码来源:BasicJMSChat.java

示例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();
}
 
开发者ID:moueimei,项目名称:flume-release-1.7.0,代码行数:21,代码来源:TestIntegrationActiveMQ.java

示例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;
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:17,代码来源:MutatieNotificatieServiceImpl.java

示例6: createTextMessage

import javax.jms.TextMessage; //导入方法依赖的package包/类
public TextMessage createTextMessage(String text) throws JMSException {
    TextMessage textMessage = new ProxyTextMessage();
    textMessage.setText(text);

    return textMessage;
}
 
开发者ID:zhaojunfei,项目名称:lemon,代码行数:7,代码来源:ProxySession.java


注:本文中的javax.jms.TextMessage.setText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。