本文整理了Java中org.springframework.amqp.core.Address.getRoutingKey()
方法的一些代码示例,展示了Address.getRoutingKey()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getRoutingKey()
方法的具体详情如下:
包路径:org.springframework.amqp.core.Address
类名称:Address
方法名:getRoutingKey
暂无
代码示例来源:origin: spring-projects/spring-integration
replyTo.getRoutingKey(), reply.getPayload(), messagePostProcessor);
代码示例来源:origin: spring-projects/spring-integration
@Test
public void verifyLifeCycle() {
Object gateway = context.getBean("autoStartFalseGateway");
assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(gateway, "autoStartup"));
assertEquals(123, TestUtils.getPropertyValue(gateway, "phase"));
assertFalse(TestUtils.getPropertyValue(gateway, "messageListenerContainer.missingQueuesFatal", Boolean.class));
Object amqpTemplate = context.getBean("amqpTemplate");
assertSame(amqpTemplate, TestUtils.getPropertyValue(gateway, "amqpTemplate"));
Address defaultReplyTo = TestUtils.getPropertyValue(gateway, "defaultReplyTo", Address.class);
Address expected = new Address("fooExchange/barRoutingKey");
assertEquals(expected.getExchangeName(), defaultReplyTo.getExchangeName());
assertEquals(expected.getRoutingKey(), defaultReplyTo.getRoutingKey());
assertEquals(expected, defaultReplyTo);
}
代码示例来源:origin: spring-projects/spring-amqp
/**
* Invoked by the container during startup so it can verify the queue is correctly
* configured (if a simple reply queue name is used instead of exchange/routingKey).
* @return the queue name, if configured.
* @since 1.5
*/
@Override
@Nullable
public Collection<String> expectedQueueNames() {
this.isListener = true;
Collection<String> replyQueue = null;
if (this.replyAddress == null || this.replyAddress.equals(Address.AMQ_RABBITMQ_REPLY_TO)) {
throw new IllegalStateException("A listener container must not be provided when using direct reply-to");
}
else {
Address address = new Address(this.replyAddress);
if ("".equals(address.getExchangeName())) {
replyQueue = Collections.singletonList(address.getRoutingKey());
}
else {
if (logger.isInfoEnabled()) {
logger.info("Cannot verify reply queue because 'replyAddress' is not a simple queue name: "
+ this.replyAddress);
}
}
}
return replyQueue;
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
/**
* Invoked by the container during startup so it can verify the queue is correctly
* configured (if a simple reply queue name is used instead of exchange/routingKey).
* @return the queue name, if configured.
* @since 1.5
*/
@Override
@Nullable
public Collection<String> expectedQueueNames() {
this.isListener = true;
Collection<String> replyQueue = null;
if (this.replyAddress == null || this.replyAddress.equals(Address.AMQ_RABBITMQ_REPLY_TO)) {
throw new IllegalStateException("A listener container must not be provided when using direct reply-to");
}
else {
Address address = new Address(this.replyAddress);
if ("".equals(address.getExchangeName())) {
replyQueue = Collections.singletonList(address.getRoutingKey());
}
else {
if (logger.isInfoEnabled()) {
logger.info("Cannot verify reply queue because 'replyAddress' is not a simple queue name: "
+ this.replyAddress);
}
}
}
return replyQueue;
}
代码示例来源:origin: spring-projects/spring-amqp
protected void doPublish(Channel channel, Address replyTo, Message message) throws IOException {
channel.basicPublish(replyTo.getExchangeName(), replyTo.getRoutingKey(), this.mandatoryPublish,
this.messagePropertiesConverter.fromMessageProperties(message.getMessageProperties(), this.encoding),
message.getBody());
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
protected void doPublish(Channel channel, Address replyTo, Message message) throws IOException {
channel.basicPublish(replyTo.getExchangeName(), replyTo.getRoutingKey(), this.mandatoryPublish,
this.messagePropertiesConverter.fromMessageProperties(message.getMessageProperties(), this.encoding),
message.getBody());
}
代码示例来源:origin: spring-projects/spring-amqp
private void send(Object object, Address replyToAddress, Message requestMessage) {
Message message = this.messageConverter.toMessage(object, new MessageProperties());
message.getMessageProperties().setCorrelationId(requestMessage.getMessageProperties().getCorrelationId());
getAmqpTemplate().send(replyToAddress.getExchangeName(), replyToAddress.getRoutingKey(), message);
}
代码示例来源:origin: spring-projects/spring-amqp
assertThat(replyAddress.get(), notNullValue());
assertThat(replyAddress.get().getExchangeName(), equalTo("foo"));
assertThat(replyAddress.get().getRoutingKey(), equalTo("bar"));
assertThat(throwable.get(), sameInstance(ex));
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void testReplyTo() throws Exception {
MessageProperties properties = new MessageProperties();
properties.setReplyTo("foo/bar");
assertEquals("bar", properties.getReplyToAddress().getRoutingKey());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void parse() {
String replyToUri = "direct://my-exchange/routing-key";
Address address = new Address(replyToUri);
assertEquals("my-exchange", address.getExchangeName());
assertEquals("routing-key", address.getRoutingKey());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void parseUnstructuredWithRoutingKeyOnly() {
Address address = new Address("my-routing-key");
assertEquals("my-routing-key", address.getRoutingKey());
assertEquals("/my-routing-key", address.toString());
address = new Address("/foo");
assertEquals("foo", address.getRoutingKey());
assertEquals("/foo", address.toString());
address = new Address("bar/baz");
assertEquals("bar", address.getExchangeName());
assertEquals("baz", address.getRoutingKey());
assertEquals("bar/baz", address.toString());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void testDirectReplyTo() {
String replyTo = Address.AMQ_RABBITMQ_REPLY_TO + ".ab/cd/ef";
MessageProperties props = new MessageProperties();
props.setReplyTo(replyTo);
Message message = new Message("foo".getBytes(), props);
Address address = message.getMessageProperties().getReplyToAddress();
assertEquals("", address.getExchangeName());
assertEquals(replyTo, address.getRoutingKey());
address = props.getReplyToAddress();
assertEquals("", address.getExchangeName());
assertEquals(replyTo, address.getRoutingKey());
}
代码示例来源:origin: spring-projects/spring-amqp
private <S> void doSendReply(final ReplyToAddressCallback<S> replyToAddressCallback, Channel channel,
Message receiveMessage, S reply) throws Exception { // NOSONAR TODO: change to IOException in 2.2.
Address replyTo = replyToAddressCallback.getReplyToAddress(receiveMessage, reply);
Message replyMessage = convertMessageIfNecessary(reply);
MessageProperties receiveMessageProperties = receiveMessage.getMessageProperties();
MessageProperties replyMessageProperties = replyMessage.getMessageProperties();
Object correlation = this.correlationKey == null
? receiveMessageProperties.getCorrelationId()
: receiveMessageProperties.getHeaders().get(this.correlationKey);
if (this.correlationKey == null || correlation == null) {
// using standard correlationId property
if (correlation == null) {
String messageId = receiveMessageProperties.getMessageId();
if (messageId != null) {
correlation = messageId;
}
}
replyMessageProperties.setCorrelationId((String) correlation);
}
else {
replyMessageProperties.setHeader(this.correlationKey, correlation);
}
// 'doSend()' takes care of 'channel.txCommit()'.
doSend(channel,
replyTo.getExchangeName(),
replyTo.getRoutingKey(),
replyMessage,
RabbitTemplate.this.returnCallback != null && isMandatoryFor(replyMessage),
null);
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
private <S> void doSendReply(final ReplyToAddressCallback<S> replyToAddressCallback, Channel channel,
Message receiveMessage, S reply) throws Exception { // NOSONAR TODO: change to IOException in 2.2.
Address replyTo = replyToAddressCallback.getReplyToAddress(receiveMessage, reply);
Message replyMessage = convertMessageIfNecessary(reply);
MessageProperties receiveMessageProperties = receiveMessage.getMessageProperties();
MessageProperties replyMessageProperties = replyMessage.getMessageProperties();
Object correlation = this.correlationKey == null
? receiveMessageProperties.getCorrelationId()
: receiveMessageProperties.getHeaders().get(this.correlationKey);
if (this.correlationKey == null || correlation == null) {
// using standard correlationId property
if (correlation == null) {
String messageId = receiveMessageProperties.getMessageId();
if (messageId != null) {
correlation = messageId;
}
}
replyMessageProperties.setCorrelationId((String) correlation);
}
else {
replyMessageProperties.setHeader(this.correlationKey, correlation);
}
// 'doSend()' takes care of 'channel.txCommit()'.
doSend(channel,
replyTo.getExchangeName(),
replyTo.getRoutingKey(),
replyMessage,
RabbitTemplate.this.returnCallback != null && isMandatoryFor(replyMessage),
null);
}
代码示例来源:origin: spring-projects/spring-amqp
+ replyTo.getRoutingKey() + "]");
if (this.retryTemplate == null) {
doPublish(channel, replyTo, message);
代码示例来源:origin: org.springframework.amqp/spring-rabbit
+ replyTo.getRoutingKey() + "]");
if (this.retryTemplate == null) {
doPublish(channel, replyTo, message);
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void parseWithoutRoutingKey() {
Address address = new Address("fanout://my-exchange");
assertEquals("my-exchange", address.getExchangeName());
assertEquals("", address.getRoutingKey());
assertEquals("my-exchange/", address.toString());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void testEmpty() {
Address address = new Address("/");
assertEquals("", address.getExchangeName());
assertEquals("", address.getRoutingKey());
assertEquals("/", address.toString());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void parseWithDefaultExchangeAndRoutingKey() {
Address address = new Address("direct:///routing-key");
assertEquals("", address.getExchangeName());
assertEquals("routing-key", address.getRoutingKey());
assertEquals("/routing-key", address.toString());
}
代码示例来源:origin: com.bluelock/camel-spring-amqp
endpoint.getAmqpTemplate().send(replyToAddress.getExchangeName(), replyToAddress.getRoutingKey(), replyMessage.toAMQPMessage(msgConverter));
} catch(AmqpConnectException e) {
LOG.error("AMQP Connection error, marking this connection as failed");
内容来源于网络,如有侵权,请联系作者删除!