org.springframework.amqp.core.Address.getRoutingKey()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(193)

本文整理了Java中org.springframework.amqp.core.Address.getRoutingKey()方法的一些代码示例,展示了Address.getRoutingKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.getRoutingKey()方法的具体详情如下:
包路径:org.springframework.amqp.core.Address
类名称:Address
方法名:getRoutingKey

Address.getRoutingKey介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-integration

  1. replyTo.getRoutingKey(), reply.getPayload(), messagePostProcessor);

代码示例来源:origin: spring-projects/spring-integration

  1. @Test
  2. public void verifyLifeCycle() {
  3. Object gateway = context.getBean("autoStartFalseGateway");
  4. assertEquals(Boolean.FALSE, TestUtils.getPropertyValue(gateway, "autoStartup"));
  5. assertEquals(123, TestUtils.getPropertyValue(gateway, "phase"));
  6. assertFalse(TestUtils.getPropertyValue(gateway, "messageListenerContainer.missingQueuesFatal", Boolean.class));
  7. Object amqpTemplate = context.getBean("amqpTemplate");
  8. assertSame(amqpTemplate, TestUtils.getPropertyValue(gateway, "amqpTemplate"));
  9. Address defaultReplyTo = TestUtils.getPropertyValue(gateway, "defaultReplyTo", Address.class);
  10. Address expected = new Address("fooExchange/barRoutingKey");
  11. assertEquals(expected.getExchangeName(), defaultReplyTo.getExchangeName());
  12. assertEquals(expected.getRoutingKey(), defaultReplyTo.getRoutingKey());
  13. assertEquals(expected, defaultReplyTo);
  14. }

代码示例来源:origin: spring-projects/spring-amqp

  1. /**
  2. * Invoked by the container during startup so it can verify the queue is correctly
  3. * configured (if a simple reply queue name is used instead of exchange/routingKey).
  4. * @return the queue name, if configured.
  5. * @since 1.5
  6. */
  7. @Override
  8. @Nullable
  9. public Collection<String> expectedQueueNames() {
  10. this.isListener = true;
  11. Collection<String> replyQueue = null;
  12. if (this.replyAddress == null || this.replyAddress.equals(Address.AMQ_RABBITMQ_REPLY_TO)) {
  13. throw new IllegalStateException("A listener container must not be provided when using direct reply-to");
  14. }
  15. else {
  16. Address address = new Address(this.replyAddress);
  17. if ("".equals(address.getExchangeName())) {
  18. replyQueue = Collections.singletonList(address.getRoutingKey());
  19. }
  20. else {
  21. if (logger.isInfoEnabled()) {
  22. logger.info("Cannot verify reply queue because 'replyAddress' is not a simple queue name: "
  23. + this.replyAddress);
  24. }
  25. }
  26. }
  27. return replyQueue;
  28. }

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. /**
  2. * Invoked by the container during startup so it can verify the queue is correctly
  3. * configured (if a simple reply queue name is used instead of exchange/routingKey).
  4. * @return the queue name, if configured.
  5. * @since 1.5
  6. */
  7. @Override
  8. @Nullable
  9. public Collection<String> expectedQueueNames() {
  10. this.isListener = true;
  11. Collection<String> replyQueue = null;
  12. if (this.replyAddress == null || this.replyAddress.equals(Address.AMQ_RABBITMQ_REPLY_TO)) {
  13. throw new IllegalStateException("A listener container must not be provided when using direct reply-to");
  14. }
  15. else {
  16. Address address = new Address(this.replyAddress);
  17. if ("".equals(address.getExchangeName())) {
  18. replyQueue = Collections.singletonList(address.getRoutingKey());
  19. }
  20. else {
  21. if (logger.isInfoEnabled()) {
  22. logger.info("Cannot verify reply queue because 'replyAddress' is not a simple queue name: "
  23. + this.replyAddress);
  24. }
  25. }
  26. }
  27. return replyQueue;
  28. }

代码示例来源:origin: spring-projects/spring-amqp

  1. protected void doPublish(Channel channel, Address replyTo, Message message) throws IOException {
  2. channel.basicPublish(replyTo.getExchangeName(), replyTo.getRoutingKey(), this.mandatoryPublish,
  3. this.messagePropertiesConverter.fromMessageProperties(message.getMessageProperties(), this.encoding),
  4. message.getBody());
  5. }

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. protected void doPublish(Channel channel, Address replyTo, Message message) throws IOException {
  2. channel.basicPublish(replyTo.getExchangeName(), replyTo.getRoutingKey(), this.mandatoryPublish,
  3. this.messagePropertiesConverter.fromMessageProperties(message.getMessageProperties(), this.encoding),
  4. message.getBody());
  5. }

代码示例来源:origin: spring-projects/spring-amqp

  1. private void send(Object object, Address replyToAddress, Message requestMessage) {
  2. Message message = this.messageConverter.toMessage(object, new MessageProperties());
  3. message.getMessageProperties().setCorrelationId(requestMessage.getMessageProperties().getCorrelationId());
  4. getAmqpTemplate().send(replyToAddress.getExchangeName(), replyToAddress.getRoutingKey(), message);
  5. }

代码示例来源:origin: spring-projects/spring-amqp

  1. assertThat(replyAddress.get(), notNullValue());
  2. assertThat(replyAddress.get().getExchangeName(), equalTo("foo"));
  3. assertThat(replyAddress.get().getRoutingKey(), equalTo("bar"));
  4. assertThat(throwable.get(), sameInstance(ex));

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void testReplyTo() throws Exception {
  3. MessageProperties properties = new MessageProperties();
  4. properties.setReplyTo("foo/bar");
  5. assertEquals("bar", properties.getReplyToAddress().getRoutingKey());
  6. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void parse() {
  3. String replyToUri = "direct://my-exchange/routing-key";
  4. Address address = new Address(replyToUri);
  5. assertEquals("my-exchange", address.getExchangeName());
  6. assertEquals("routing-key", address.getRoutingKey());
  7. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void parseUnstructuredWithRoutingKeyOnly() {
  3. Address address = new Address("my-routing-key");
  4. assertEquals("my-routing-key", address.getRoutingKey());
  5. assertEquals("/my-routing-key", address.toString());
  6. address = new Address("/foo");
  7. assertEquals("foo", address.getRoutingKey());
  8. assertEquals("/foo", address.toString());
  9. address = new Address("bar/baz");
  10. assertEquals("bar", address.getExchangeName());
  11. assertEquals("baz", address.getRoutingKey());
  12. assertEquals("bar/baz", address.toString());
  13. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void testDirectReplyTo() {
  3. String replyTo = Address.AMQ_RABBITMQ_REPLY_TO + ".ab/cd/ef";
  4. MessageProperties props = new MessageProperties();
  5. props.setReplyTo(replyTo);
  6. Message message = new Message("foo".getBytes(), props);
  7. Address address = message.getMessageProperties().getReplyToAddress();
  8. assertEquals("", address.getExchangeName());
  9. assertEquals(replyTo, address.getRoutingKey());
  10. address = props.getReplyToAddress();
  11. assertEquals("", address.getExchangeName());
  12. assertEquals(replyTo, address.getRoutingKey());
  13. }

代码示例来源:origin: spring-projects/spring-amqp

  1. private <S> void doSendReply(final ReplyToAddressCallback<S> replyToAddressCallback, Channel channel,
  2. Message receiveMessage, S reply) throws Exception { // NOSONAR TODO: change to IOException in 2.2.
  3. Address replyTo = replyToAddressCallback.getReplyToAddress(receiveMessage, reply);
  4. Message replyMessage = convertMessageIfNecessary(reply);
  5. MessageProperties receiveMessageProperties = receiveMessage.getMessageProperties();
  6. MessageProperties replyMessageProperties = replyMessage.getMessageProperties();
  7. Object correlation = this.correlationKey == null
  8. ? receiveMessageProperties.getCorrelationId()
  9. : receiveMessageProperties.getHeaders().get(this.correlationKey);
  10. if (this.correlationKey == null || correlation == null) {
  11. // using standard correlationId property
  12. if (correlation == null) {
  13. String messageId = receiveMessageProperties.getMessageId();
  14. if (messageId != null) {
  15. correlation = messageId;
  16. }
  17. }
  18. replyMessageProperties.setCorrelationId((String) correlation);
  19. }
  20. else {
  21. replyMessageProperties.setHeader(this.correlationKey, correlation);
  22. }
  23. // 'doSend()' takes care of 'channel.txCommit()'.
  24. doSend(channel,
  25. replyTo.getExchangeName(),
  26. replyTo.getRoutingKey(),
  27. replyMessage,
  28. RabbitTemplate.this.returnCallback != null && isMandatoryFor(replyMessage),
  29. null);
  30. }

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. private <S> void doSendReply(final ReplyToAddressCallback<S> replyToAddressCallback, Channel channel,
  2. Message receiveMessage, S reply) throws Exception { // NOSONAR TODO: change to IOException in 2.2.
  3. Address replyTo = replyToAddressCallback.getReplyToAddress(receiveMessage, reply);
  4. Message replyMessage = convertMessageIfNecessary(reply);
  5. MessageProperties receiveMessageProperties = receiveMessage.getMessageProperties();
  6. MessageProperties replyMessageProperties = replyMessage.getMessageProperties();
  7. Object correlation = this.correlationKey == null
  8. ? receiveMessageProperties.getCorrelationId()
  9. : receiveMessageProperties.getHeaders().get(this.correlationKey);
  10. if (this.correlationKey == null || correlation == null) {
  11. // using standard correlationId property
  12. if (correlation == null) {
  13. String messageId = receiveMessageProperties.getMessageId();
  14. if (messageId != null) {
  15. correlation = messageId;
  16. }
  17. }
  18. replyMessageProperties.setCorrelationId((String) correlation);
  19. }
  20. else {
  21. replyMessageProperties.setHeader(this.correlationKey, correlation);
  22. }
  23. // 'doSend()' takes care of 'channel.txCommit()'.
  24. doSend(channel,
  25. replyTo.getExchangeName(),
  26. replyTo.getRoutingKey(),
  27. replyMessage,
  28. RabbitTemplate.this.returnCallback != null && isMandatoryFor(replyMessage),
  29. null);
  30. }

代码示例来源:origin: spring-projects/spring-amqp

  1. + replyTo.getRoutingKey() + "]");
  2. if (this.retryTemplate == null) {
  3. doPublish(channel, replyTo, message);

代码示例来源:origin: org.springframework.amqp/spring-rabbit

  1. + replyTo.getRoutingKey() + "]");
  2. if (this.retryTemplate == null) {
  3. doPublish(channel, replyTo, message);

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void parseWithoutRoutingKey() {
  3. Address address = new Address("fanout://my-exchange");
  4. assertEquals("my-exchange", address.getExchangeName());
  5. assertEquals("", address.getRoutingKey());
  6. assertEquals("my-exchange/", address.toString());
  7. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void testEmpty() {
  3. Address address = new Address("/");
  4. assertEquals("", address.getExchangeName());
  5. assertEquals("", address.getRoutingKey());
  6. assertEquals("/", address.toString());
  7. }

代码示例来源:origin: spring-projects/spring-amqp

  1. @Test
  2. public void parseWithDefaultExchangeAndRoutingKey() {
  3. Address address = new Address("direct:///routing-key");
  4. assertEquals("", address.getExchangeName());
  5. assertEquals("routing-key", address.getRoutingKey());
  6. assertEquals("/routing-key", address.toString());
  7. }

代码示例来源:origin: com.bluelock/camel-spring-amqp

  1. endpoint.getAmqpTemplate().send(replyToAddress.getExchangeName(), replyToAddress.getRoutingKey(), replyMessage.toAMQPMessage(msgConverter));
  2. } catch(AmqpConnectException e) {
  3. LOG.error("AMQP Connection error, marking this connection as failed");

相关文章