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


Java TextMessage.setStringProperty方法代码示例

本文整理汇总了Java中javax.jms.TextMessage.setStringProperty方法的典型用法代码示例。如果您正苦于以下问题:Java TextMessage.setStringProperty方法的具体用法?Java TextMessage.setStringProperty怎么用?Java TextMessage.setStringProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.jms.TextMessage的用法示例。


在下文中一共展示了TextMessage.setStringProperty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: publishCiStateMessage

import javax.jms.TextMessage; //导入方法依赖的package包/类
/**
   * Publish ci state message.
   *
   * @param event the event
   */
  public void publishCiStateMessage(CiChangeStateEvent event) {
  	
try {
	TextMessage message = session.createTextMessage(gson.toJson(event));
   	message.setLongProperty("ciId", event.getCiId());
   	message.setStringProperty("type", "ci-change-state");
   	message.setStringProperty("ciState", event.getNewState());
   	producer.send(message);
   	logger.info("Published: ciId:" + event.getCiId());
   	logger.info(message.getText());
} catch (JMSException e) {
	// TODO see if we can put some durability here
	logger.error("caught Exception publishing",e);
}
  	
  }
 
开发者ID:oneops,项目名称:oneops,代码行数:22,代码来源:OpsEventPublisher.java

示例2: publishMonitor

import javax.jms.TextMessage; //导入方法依赖的package包/类
private void publishMonitor(MonitorRequest mr) throws SensorClientException {
  	
try {
	TextMessage message = null;
	message = session.createTextMessage(gson.toJson(mr));
	
	message.setStringProperty(MSG_TYPE, MSG_TYPE_MONITOR);
	message.setLongProperty(MSG_PROP_MANIFEST_ID, mr.getManifestId());
	message.setLongProperty(MSG_PROP_CI_ID, mr.getCiId());

	producer.send(message);
   	logger.info("Published: monitor for ciId:" + mr.getCiId() + "; manifestId:" + mr.getManifestId() + "; action:" + mr.getAction());
   	logger.debug(message.getText());
} catch (JMSException e) {
	logger.error("caught Exception publishing",e);
	throw new SensorClientException(e);
}
  	
  }
 
开发者ID:oneops,项目名称:oneops,代码行数:20,代码来源:MonitorPublisher.java

示例3: 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

示例4: publishMessage

import javax.jms.TextMessage; //导入方法依赖的package包/类
/**
 * Publish message.
 *
 * @param waitTaskName the wait task name
 * @param woType       the wo type
 * @throws JMSException the jMS exception
 */
public void publishMessage(String processId, String execId, CmsWorkOrderSimpleBase wo, String waitTaskName, String woType) throws JMSException {
    SimpleDateFormat format = new SimpleDateFormat(CmsConstants.SEARCH_TS_PATTERN);
    wo.getSearchTags().put(CmsConstants.REQUEST_ENQUE_TS, format.format(new Date()));
    //guarantee non empty-value for searchMap
    if (version != null && StringUtils.isNotBlank(version.getGitVersion())) {
        wo.getSearchTags().put(CONTROLLLER_VERSION_SEARCH_TAG, version.getGitVersion());
    } else {
        wo.getSearchTags().put(CONTROLLLER_VERSION_SEARCH_TAG, DEFAULT_VERSION);
    }
    TextMessage message = session.createTextMessage(gson.toJson(wo));
    String corelationId = processId + "!" + execId + "!" + waitTaskName+"!"+getCtxtId(wo);
    message.setJMSCorrelationID(corelationId);
    message.setStringProperty("task_id", corelationId);
    message.setStringProperty("type", woType);
    String queueName;
    if ("true".equals(System.getProperty(USE_SHARED_FLAG))) {
        queueName = SHARED_QUEUE;
    } else {
        queueName = (wo.getCloud().getCiAttributes().get("location").replaceAll("/", ".") + QUEUE_SUFFIX).substring(
                1);
    }
    bindingQueusMap.computeIfAbsent(queueName, k -> {
        try {
            return newMessageProducer(k);
        } catch (JMSException e) {
            throw new RuntimeException(e);
        }
    }).send(message);
    
    if (logger.isDebugEnabled()) {
        logger.debug("Published: " + message.getText());
    }

    logger.info("Posted message with id "+ corelationId +" to q: "+queueName);

}
 
开发者ID:oneops,项目名称:oneops,代码行数:44,代码来源:InductorPublisher.java

示例5: createTextMessage

import javax.jms.TextMessage; //导入方法依赖的package包/类
protected TextMessage createTextMessage(MessageData data) throws JMSException {
	TextMessage message = session.createTextMessage(data.getPayload());
	Map<String, String> headers = data.getHeaders();
	if (headers != null) {
		for (String key : headers.keySet()) {
			message.setStringProperty(key, headers.get(key));
		}
	}
	return message;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:11,代码来源:WorkflowPublisher.java

示例6: createTextMessage

import javax.jms.TextMessage; //导入方法依赖的package包/类
protected TextMessage createTextMessage(MessageData data) throws JMSException {
	TextMessage message = session.createTextMessage(data.getPayload());
	Map<String, String> headers = data.getHeaders();
	for (String key : headers.keySet()) {
		message.setStringProperty(key, headers.get(key));
	}
	return message;
}
 
开发者ID:oneops,项目名称:oneops,代码行数:9,代码来源:SearchJmsSender.java

示例7: xmitData

import javax.jms.TextMessage; //导入方法依赖的package包/类
@Override
public void xmitData(String data) {
	try {
		if(mXmitDisable == false){
			TextMessage message = session.createTextMessage(data);
	        message.setStringProperty("JMSXGroupID", "Default");
	        message.setStringProperty("JMS_SQS_DeduplicationId", deDuplicationId+(seqNum++));
	        producer.send(message);
		}
	} catch (JMSException e) {
        System.err.println( "Failed sending message: " + e.getMessage() );
        e.printStackTrace();
    }
	
}
 
开发者ID:datamachines,项目名称:KafkaToSQS,代码行数:16,代码来源:SQSProducer.java

示例8: setStringProperty

import javax.jms.TextMessage; //导入方法依赖的package包/类
private static void setStringProperty(TextMessage message, String header, String value) throws JMSException {
    LOG.debug("Setting header [{}] value [{}]", header, value);
    message.setStringProperty(header, value);
}
 
开发者ID:EsikAntony,项目名称:camunda-task-dispatcher,代码行数:5,代码来源:JmsExternalTaskSender.java

示例9: testPositiveJMSSelectorConsumerProducer

import javax.jms.TextMessage; //导入方法依赖的package包/类
@Parameters({"broker-port", "admin-username", "admin-password", "broker-hostname"})
@Test
public void testPositiveJMSSelectorConsumerProducer(String port,
                                                    String adminUsername,
                                                    String adminPassword,
                                                    String brokerHostname) throws NamingException, JMSException {
    String queueName = "testPositiveJMSSelectorConsumerProducer";
    InitialContext initialContext = ClientHelper
            .getInitialContextBuilder(adminUsername, adminPassword, brokerHostname, port)
            .withTopic(queueName)
            .build();


    TopicConnectionFactory connectionFactory
            = (TopicConnectionFactory) initialContext.lookup(ClientHelper.CONNECTION_FACTORY);
    TopicConnection connection = connectionFactory.createTopicConnection();
    connection.start();

    TopicSession subscriberSession = connection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    Topic topic = (Topic) initialContext.lookup(queueName);

    // Subscribe with a selector
    String propertyName = "MyProperty";
    String propertyValue = "propertyValue";
    String jmsPropertySelector = propertyName + " = '" + propertyValue + "'";
    TopicSubscriber consumer = subscriberSession.createSubscriber(topic, jmsPropertySelector, false);

    // publish messages with property
    TopicSession producerSession = connection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    TopicPublisher producer = producerSession.createPublisher(topic);

    int numberOfMessages = 100;
    for (int i = 0; i < numberOfMessages; i++) {
        TextMessage textMessage = producerSession.createTextMessage("Test message " + i);
        textMessage.setStringProperty(propertyName, propertyValue);
        producer.send(textMessage);
    }

    // consume messages
    for (int i = 0; i < numberOfMessages; i++) {
        Message message = consumer.receive(1000);
        Assert.assertNotNull(message, "Message #" + i + " was not received");
    }

    producerSession.close();
    connection.close();
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:48,代码来源:JMSSelectorTest.java

示例10: testNegativeJMSSelectorConsumerProducer

import javax.jms.TextMessage; //导入方法依赖的package包/类
@Parameters({"broker-port", "admin-username", "admin-password", "broker-hostname"})
@Test
public void testNegativeJMSSelectorConsumerProducer(String port,
                                                    String adminUsername,
                                                    String adminPassword,
                                                    String brokerHostname) throws NamingException, JMSException {
    String queueName = "testNegativeJMSSelectorConsumerProducer";
    InitialContext initialContext = ClientHelper
            .getInitialContextBuilder(adminUsername, adminPassword, brokerHostname, port)
            .withTopic(queueName)
            .build();

    TopicConnectionFactory connectionFactory
            = (TopicConnectionFactory) initialContext.lookup(ClientHelper.CONNECTION_FACTORY);
    TopicConnection connection = connectionFactory.createTopicConnection();
    connection.start();

    TopicSession subscriberSession = connection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    Topic topic = (Topic) initialContext.lookup(queueName);

    // Subscribe with a selector
    String propertyName = "MyProperty";
    String propertyValue = "propertyValue";
    String jmsPropertySelector = propertyName + " = '" + propertyValue + "'";
    TopicSubscriber consumer = subscriberSession.createSubscriber(topic, jmsPropertySelector, false);

    // publish messages with property
    TopicSession producerSession = connection.createTopicSession(false, TopicSession.AUTO_ACKNOWLEDGE);
    TopicPublisher producer = producerSession.createPublisher(topic);

    // Send messages with a different property value
    int numberOfMessages = 100;
    for (int i = 0; i < numberOfMessages; i++) {
        TextMessage textMessage = producerSession.createTextMessage("Test message " + i);
        textMessage.setStringProperty(propertyName, propertyValue + "-1");
        producer.send(textMessage);
    }

    // consume messages
    Message message = consumer.receive(100);
    Assert.assertNull(message, "Message received. Shouldn't receive any messages.");

    producerSession.close();
    connection.close();
}
 
开发者ID:wso2,项目名称:message-broker,代码行数:46,代码来源:JMSSelectorTest.java


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