當前位置: 首頁>>代碼示例>>Java>>正文


Java Message.getStringProperty方法代碼示例

本文整理匯總了Java中javax.jms.Message.getStringProperty方法的典型用法代碼示例。如果您正苦於以下問題:Java Message.getStringProperty方法的具體用法?Java Message.getStringProperty怎麽用?Java Message.getStringProperty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.jms.Message的用法示例。


在下文中一共展示了Message.getStringProperty方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addData

import javax.jms.Message; //導入方法依賴的package包/類
private void addData(Message message, String text) throws JMSException {
    MessageData data = new MessageData();
    data.setPayload(text);
    Map<String, String> headers = new HashMap<>();
    Enumeration<String> names = message.getPropertyNames();
    while (names.hasMoreElements()) {
        String name = names.nextElement();
        String value = message.getStringProperty(name);
        headers.put(name, value);
    }
    data.setHeaders(headers);
    messages.add(data);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:14,代碼來源:JMSConsumer.java

示例2: args

import javax.jms.Message; //導入方法依賴的package包/類
/**
 * Het advies uit te voeren op de pointcut.
 * @param message parameter van de methode
 * @throws JMSException als iets in de pointcut fout gaat
 */
@Before("nl.bzk.algemeenbrp.util.common.logging.AspectForMDC.jmsBerichtLezer() && args(message)")
public void voegMDCInformatieToe(Message message) throws JMSException {
    if (message.getStringProperty(MDC.JMS_VERWERKING_CODE) != null) {
        org.slf4j.MDC.put(VERWERKING_CODE, message.getStringProperty(MDC.JMS_VERWERKING_CODE));
    } else {
        org.slf4j.MDC.put(VERWERKING_CODE, UUID.randomUUID().toString());
    }
    org.slf4j.MDC.put(JMS_MESSAGE_ID, message.getJMSMessageID());
    if (message.getStringProperty(BERICHT_REFERENTIE) != null) {
        org.slf4j.MDC.put(SYNC_BERICHT_REFERENTIE, message.getStringProperty(BERICHT_REFERENTIE));
    } else {
        org.slf4j.MDC.remove(SYNC_BERICHT_REFERENTIE);
    }
    if (message.getStringProperty(CORRELATIE_REFERENTIE) != null) {
        org.slf4j.MDC.put(SYNC_CORRELATIE_REFERENTIE, message.getStringProperty(CORRELATIE_REFERENTIE));
    } else {
        org.slf4j.MDC.remove(SYNC_CORRELATIE_REFERENTIE);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:25,代碼來源:AspectForMDC.java

示例3: addData

import javax.jms.Message; //導入方法依賴的package包/類
private void addData(Message message, String text) throws JMSException {
	MessageData data = new MessageData();
	data.setPayload(text);
	Map<String, String> headers = new HashMap<String, String>();
	Enumeration<String> names = message.getPropertyNames();
	while (names.hasMoreElements()) {
		String name = names.nextElement();
		String value = message.getStringProperty(name);
		headers.put(name, value);
	}
	data.setHeaders(headers);
	messages.add(data);
}
 
開發者ID:oneops,項目名稱:oneops,代碼行數:14,代碼來源:JMSConsumer.java

示例4: leesBerichtReferentie

import javax.jms.Message; //導入方法依賴的package包/類
private String leesBerichtReferentie(final Message message) {
    try {
        return message.getStringProperty(BERICHT_REFERENTIE);
    } catch (final JMSException e) {
        throw JmsUtils.convertJmsAccessException(e);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:8,代碼來源:VrijBerichtMessageListener.java

示例5: leesBerichtReferentie

import javax.jms.Message; //導入方法依賴的package包/類
private static String leesBerichtReferentie(final Message message) {
    try {
        return message.getStringProperty(BERICHT_REFERENTIE);
    } catch (final JMSException e) {
        throw new VerzendOntvangstException("Kan berichtreferentie niet lezen", e);
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:8,代碼來源:GbaBijhoudingsMessageListener.java

示例6: publish

import javax.jms.Message; //導入方法依賴的package包/類
@Override
public void publish(final Message message, final KafkaTemplate<String, byte[]> kafkaTemplate) {

	try {
		final byte[] effectivePayload = JmsUtil.getPayload((BytesMessage) message);
		final String sourceTopic = message.getStringProperty("JMSDestination");
		final String destTopic = this.getDestTopic(sourceTopic);
		kafkaTemplate.send(destTopic, effectivePayload);
	} catch (final Throwable t) {
		LOG.error("Exception occured", t);
	}
}
 
開發者ID:dcsolutions,項目名稱:kalinka,代碼行數:13,代碼來源:MqttSparkClusterJmsMessagePublisher.java

示例7: onMessage

import javax.jms.Message; //導入方法依賴的package包/類
@Override
public void onMessage(final Message msg) {

	try {
		final String destination = msg.getStringProperty("JMSDestination");
		final IMessagePublisher<Message, K, V> publisher = this.messagePublisherProvider.getPublisher(msg.getStringProperty("JMSDestination"));
		if (publisher == null) {
			LOG.warn("No publisher found for destination={}", destination);
			return;
		}
		publisher.publish(msg, this.kafkaTemplate);
	} catch (final Throwable t) {
		throw new RuntimeException(t);
	}
}
 
開發者ID:dcsolutions,項目名稱:kalinka,代碼行數:16,代碼來源:JmsMessageListener.java

示例8: isMessageOwner

import javax.jms.Message; //導入方法依賴的package包/類
/** Returns true if the input Message was created by the currently authenticated user.
 * @param message the JMS Message.
 * @return true if the input Message was created by the currently authenticated user.
 */
private static boolean isMessageOwner(Message message) throws JMSException {
    String currentUserId = SecurityManager.getPrincipal() != null ? SecurityManager.getPrincipal().getName() : null;
    String createdBy = message.getStringProperty(HEADER_USER_ID);
    boolean result = currentUserId != null && currentUserId.equals(createdBy);
    if (!result && log.isDebugEnabled())
        log.debug(currentUserId + " is not owner of the message " + message.getJMSMessageID() + ", which was created by " + createdBy);
    return result;
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:13,代碼來源:JmsBrowser.java

示例9: getMessageIdForBusinessEventLog

import javax.jms.Message; //導入方法依賴的package包/類
/** Returns the messageId to be used for retrieving the BusinessEventLogs for a Message.
 * @param input The criteria based on which an object will be retrieved.
 * @throws ApplicationExceptions This will be thrown if the criteria contains invalid data.
 * @throws FrameworkException Indicates some system error.
 * @return The messageId.
 */
public String getMessageIdForBusinessEventLog(MessageViewerInDto input) throws FrameworkException, ApplicationExceptions{
    try{
        Message message = findMessage(input);
        return message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_MESSAGE_ID) != null ? message.getStringProperty(JmsBrowser.HEADER_ORIGINAL_MESSAGE_ID) : message.getJMSMessageID();
    } catch(JMSException e) {
        throw new JaffaMessagingFrameworkException(JaffaMessagingFrameworkException.MESSAGE_INFO_MISSING, null, e);
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:15,代碼來源:MessageViewerTx.java

示例10: testDlcWithBasicRecover

import javax.jms.Message; //導入方法依賴的package包/類
@Parameters({ "broker-hostname", "broker-port", "admin-username", "admin-password" })
@Test
public void testDlcWithBasicRecover(String brokerHostname,
                                         String port,
                                         String adminUsername,
                                         String adminPassword) throws Exception {
    String queueName = "testDlcWithBasicRecover";
    String dlcQueueName = "amq.dlq";
    InitialContext initialContextForQueue = ClientHelper
            .getInitialContextBuilder(adminUsername, adminPassword, brokerHostname, port)
            .withQueue(queueName)
            .withQueue(dlcQueueName)
            .build();

    ConnectionFactory connectionFactory
            = (ConnectionFactory) initialContextForQueue.lookup(ClientHelper.CONNECTION_FACTORY);
    Connection connection = connectionFactory.createConnection();
    connection.start();

    // publish message
    Session producerSession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    Queue queue = producerSession.createQueue(queueName);
    MessageProducer producer = producerSession.createProducer(queue);

    producer.send(producerSession.createTextMessage("Message for DLC test"));
    producerSession.close();

    // Consume published messages
    Session subscriberSession = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
    Destination subscriberDestination = (Destination) initialContextForQueue.lookup(queueName);
    MessageConsumer consumer = subscriberSession.createConsumer(subscriberDestination);

    for (int iteration = 0; iteration < 6; iteration++) {
        Message message = consumer.receive(5000);
        Assert.assertNotNull(message, "Message was not received");
        subscriberSession.recover();
    }

    Connection dlcConsumerConnection = connectionFactory.createConnection();
    dlcConsumerConnection.start();
    Session dlcConsumerSession = dlcConsumerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
    MessageConsumer dlcConsumer = dlcConsumerSession.createConsumer((Destination) initialContextForQueue.lookup(
            dlcQueueName));

    Message dlcMessage = dlcConsumer.receive(5000);
    Assert.assertNotNull(dlcMessage, "Dead lettered message was not received" + dlcMessage);
    String originQueue = dlcMessage.getStringProperty("x-origin-queue");
    Assert.assertEquals(originQueue, queueName, "Origin queue name did not match" + dlcMessage);
    String originExchange = dlcMessage.getStringProperty("x-origin-exchange");
    Assert.assertEquals(originExchange, "amq.direct", "Origin exchange name did not match" + dlcMessage);
    String originRoutingKey = dlcMessage.getStringProperty("x-origin-routing-key");
    Assert.assertEquals(originRoutingKey, queueName, "Origin routing key did not match" + dlcMessage);

    dlcConsumerConnection.close();
    connection.close();
}
 
開發者ID:wso2,項目名稱:message-broker,代碼行數:57,代碼來源:DeadLetterChannelTest.java


注:本文中的javax.jms.Message.getStringProperty方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。