當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。