本文整理匯總了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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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();
}