本文整理了Java中org.springframework.amqp.core.Address.<init>()
方法的一些代码示例,展示了Address.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Address.<init>()
方法的具体详情如下:
包路径:org.springframework.amqp.core.Address
类名称:Address
方法名:<init>
[英]Create an Address instance from a structured String with the form
(exchange)/(routingKey)
.
[中]使用格式为
(exchange)/(routingKey)
的结构化字符串创建地址实例。
代码示例来源:origin: spring-projects/spring-integration
/**
* The {@code defaultReplyTo} address with the form
* <pre class="code">
* (exchange)/(routingKey)
* </pre>
* or
* <pre class="code">
* (queueName)
* </pre>
* if the request message doesn't have a {@code replyTo} property.
* The second form uses the default exchange ("") and the queue name as
* the routing key.
* @param defaultReplyTo the default {@code replyTo} address to use.
* @since 4.2
* @see Address
*/
public void setDefaultReplyTo(String defaultReplyTo) {
this.defaultReplyTo = new Address(defaultReplyTo);
}
代码示例来源:origin: spring-projects/spring-integration
String replyToProperty = message.getMessageProperties().getReplyTo();
if (replyToProperty != null) {
replyTo = new Address(replyToProperty);
代码示例来源:origin: spring-projects/spring-amqp
public Address getReplyToAddress() {
return (this.replyTo != null) ? new Address(this.replyTo) : null;
}
代码示例来源:origin: org.springframework.integration/spring-integration-amqp
/**
* The {@code defaultReplyTo} address with the form
* <pre class="code">
* (exchange)/(routingKey)
* </pre>
* or
* <pre class="code">
* (queueName)
* </pre>
* if the request message doesn't have a {@code replyTo} property.
* The second form uses the default exchange ("") and the queue name as
* the routing key.
* @param defaultReplyTo the default {@code replyTo} address to use.
* @since 4.2
* @see Address
*/
public void setDefaultReplyTo(String defaultReplyTo) {
this.defaultReplyTo = new Address(defaultReplyTo);
}
代码示例来源:origin: spring-projects/spring-amqp
@Override
public <R, S> boolean receiveAndReply(final String queueName, ReceiveAndReplyCallback<R, S> callback, final String replyExchange,
final String replyRoutingKey) throws AmqpException {
return receiveAndReply(queueName, callback,
(request, reply) -> new Address(replyExchange, replyRoutingKey));
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
@Override
public <R, S> boolean receiveAndReply(final String queueName, ReceiveAndReplyCallback<R, S> callback, final String replyExchange,
final String replyRoutingKey) throws AmqpException {
return receiveAndReply(queueName, callback,
(request, reply) -> new Address(replyExchange, replyRoutingKey));
}
代码示例来源: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
private Address evaluateReplyTo(Message request, Object source, Object result, Expression expression) {
Address replyTo = null;
Object value = expression.getValue(this.evalContext, new ReplyExpressionRoot(request, source, result));
Assert.state(value instanceof String || value instanceof Address,
"response expression must evaluate to a String or Address");
if (value instanceof String) {
replyTo = new Address((String) value);
}
else {
replyTo = (Address) value;
}
return replyTo;
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
private Address evaluateReplyTo(Message request, Object source, Object result, Expression expression) {
Address replyTo = null;
Object value = expression.getValue(this.evalContext, new ReplyExpressionRoot(request, source, result));
Assert.state(value instanceof String || value instanceof Address,
"response expression must evaluate to a String or Address");
if (value instanceof String) {
replyTo = new Address((String) value);
}
else {
replyTo = (Address) value;
}
return replyTo;
}
代码示例来源:origin: org.springframework.amqp/spring-rabbit
/**
* Set the default replyTo address to use when sending response messages.
* This is only used if the replyTo from the received message is null.
* <p>
* Response destinations are only relevant for listener methods
* that return result objects, which will be wrapped in
* a response message and sent to a response destination.
* <p>
* It can be a string surrounded by "!{...}" in which case the expression is
* evaluated at runtime; see the reference manual for more information.
* @param defaultReplyTo The exchange.
* @since 1.6
*/
public void setResponseAddress(String defaultReplyTo) {
if (defaultReplyTo.startsWith(PARSER_CONTEXT.getExpressionPrefix())) {
this.responseExpression = PARSER.parseExpression(defaultReplyTo, PARSER_CONTEXT);
}
else {
this.responseAddress = new Address(defaultReplyTo);
}
}
代码示例来源:origin: spring-projects/spring-amqp
/**
* Set the default replyTo address to use when sending response messages.
* This is only used if the replyTo from the received message is null.
* <p>
* Response destinations are only relevant for listener methods
* that return result objects, which will be wrapped in
* a response message and sent to a response destination.
* <p>
* It can be a string surrounded by "!{...}" in which case the expression is
* evaluated at runtime; see the reference manual for more information.
* @param defaultReplyTo The exchange.
* @since 1.6
*/
public void setResponseAddress(String defaultReplyTo) {
if (defaultReplyTo.startsWith(PARSER_CONTEXT.getExpressionPrefix())) {
this.responseExpression = PARSER.parseExpression(defaultReplyTo, PARSER_CONTEXT);
}
else {
this.responseAddress = new Address(defaultReplyTo);
}
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void testEquals() {
assertEquals(new Address("foo/bar"), new Address("foo/bar"));
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void toStringCheck() {
Address address = new Address("my-exchange", "routing-key");
String replyToUri = "my-exchange/routing-key";
Assert.assertEquals(replyToUri, address.toString());
}
代码示例来源: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 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
@Override
public Object convertSendAndReceive(Object payload) throws AmqpException {
Object[] arguments = ((RemoteInvocation) payload).getArguments();
if (arguments.length == 1 && arguments[0].equals("timeout")) {
return null;
}
MessageConverter messageConverter = serviceExporter.getMessageConverter();
Address replyTo = new Address("fakeExchangeName", "fakeRoutingKey");
MessageProperties messageProperties = new MessageProperties();
messageProperties.setReplyToAddress(replyTo);
Message message = messageConverter.toMessage(payload, messageProperties);
serviceExporter.onMessage(message);
Message resultMessage = sentSavingTemplate.getLastMessage();
return messageConverter.fromMessage(resultMessage);
}
};
代码示例来源: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 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 parseWithDefaultExchangeAndRoutingKey() {
Address address = new Address("direct:///routing-key");
assertEquals("", address.getExchangeName());
assertEquals("routing-key", address.getRoutingKey());
assertEquals("/routing-key", address.toString());
}
代码示例来源:origin: spring-projects/spring-amqp
@Test
public void processAndReplyUsingReplyTo() throws Exception {
MessagingMessageListenerAdapter listener = createDefaultInstance(String.class);
listener.setMandatoryPublish(true);
String body = "echo text";
Address replyTo = new Address("replyToQueue", "myRouting");
MessageProperties properties = new MessageProperties();
properties.setReplyToAddress(replyTo);
org.springframework.amqp.core.Message message = MessageTestUtils.createTextMessage(body, properties);
processAndReply(listener, message, "replyToQueue", "myRouting", true, null);
assertDefaultListenerMethodInvocation();
}
内容来源于网络,如有侵权,请联系作者删除!