Extract exchange from URI
Signed-off-by: SirWayne <dennis.melzer@bosch-si.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.eclipse.hawkbit.amqp;
|
package org.eclipse.hawkbit.amqp;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import org.springframework.amqp.core.Message;
|
import org.springframework.amqp.core.Message;
|
||||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||||
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
|
import org.springframework.amqp.support.converter.AbstractJavaTypeMapper;
|
||||||
@@ -55,4 +57,8 @@ public class BaseAmqpService {
|
|||||||
return (T) messageConverter.fromMessage(message);
|
return (T) messageConverter.fromMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getExchangeFromAmqpUri(final URI amqpUri) {
|
||||||
|
return amqpUri.getPath().substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class DefaultAmqpSenderService extends BaseAmqpService implements AmqpSen
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(final Message message, final URI uri) {
|
public void sendMessage(final Message message, final URI uri) {
|
||||||
spInternalConnectorTemplate.send(uri.getPath(), message);
|
spInternalConnectorTemplate.send(getExchangeFromAmqpUri(uri), message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -108,8 +108,7 @@ public final class IpUtil {
|
|||||||
* If the given string not parsable
|
* If the given string not parsable
|
||||||
*/
|
*/
|
||||||
public static URI createAmqpUri(final String virtualHost, final String exchange) {
|
public static URI createAmqpUri(final String virtualHost, final String exchange) {
|
||||||
// TODO check
|
return createUri(AMPQP_SCHEME, virtualHost).resolve("/" + exchange);
|
||||||
return createUri(AMPQP_SCHEME, virtualHost).resolve(exchange);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ public class IpUtilTest {
|
|||||||
assertFalse(IpUtil.isHttpUri(amqpUri));
|
assertFalse(IpUtil.isHttpUri(amqpUri));
|
||||||
assertEquals(host, amqpUri.getHost());
|
assertEquals(host, amqpUri.getHost());
|
||||||
assertEquals("amqp", amqpUri.getScheme());
|
assertEquals("amqp", amqpUri.getScheme());
|
||||||
assertEquals("path", amqpUri.getPath());
|
assertEquals("/path", amqpUri.getRawPath());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalArgumentException.class)
|
@Test(expected = IllegalArgumentException.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user