Get payload info from pdu with logica SMPP - smpp

How to get payload information from pdu with logica SMPP?

Its easy:
DeliverSm dSm = (DeliverSM)pdu;
byte[] payLoad = deliverSM.getMessagePayload().getBuffer();

Related

Request compression in Akka HTTP

Is there a way to automatically compress requests with Akka HTTP client?
Example request code:
val httpRequest = HttpRequest(
HttpMethods.POST,
"myurl",
HttpEntity(ContentTypes.`application/json`, myJsonString)
)
val response = Http().singleRequest(httpRequest)
I've only found info on decompressing responses in documentation: https://doc.akka.io/docs/akka-http/current/common/encoding.html
For example, I can do this in Play Framework WSClient by setting play.ws.compressionEnabled = true in config: https://www.playframework.com/documentation/2.8.x/ScalaWS

Get IP of producers sending messages to queue/exchange

For troubleshooting purpose I want to get list of producers sending messages to a particular queue or exchange. I dont see any option in rabbitmq console to get the above details. Some producers are piling up a paricular queue, I am trying to figure out the IP of producer piling up messages in the queue.
Can any one please guide me on this.
you don't have this information by default, but you can use the message headers to do that.
for example:
string message = "Hello World!";
var body = Encoding.UTF8.GetBytes(message);
var properties = new BasicProperties();
properties.Headers = new Dictionary<string, object>();
properties.Headers.Add("senderip", InetAddress.getLocalHost().getHostAddress());
properties.Headers.Add("custominfo", "info" );
channel.BasicPublish(exchange: "", routingKey: "mykey", basicProperties: properties,body: body);
When you recevice the message you can decode the headers

NServiceBus Reverts back to XmlSerilizer for no reason

I am having issues with NSB reverting to the Xml Serializer for no apparent reason which obvisouly causes an error when trying to deserialize the message. Below is an excerpt from the log, as you can see some come through from the same source as Json and then all of a sudden XML!
2018-06-05 08:51:36.924 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body:
2018-06-05 08:51:37.026 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter {"Exchange":"Binance","Symbol":"SYSBTC","MinutesPerCandle":15}
2018-06-05 08:51:38.505 INFO Stockly.Services.QuoteService.QuoteHandler Received quote request for SYSBTC and retrived 1000 candles
2018-06-05 08:51:38.725 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body:
2018-06-05 08:51:38.728 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter {"Exchange":"Binance","Symbol":"DASHBTC","MinutesPerCandle":15}
2018-06-05 08:51:39.194 INFO Stockly.Services.QuoteService.QuoteHandler Received quote request for DASHBTC and retrived 1000 candles
2018-06-05 08:51:39.228 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body:
2018-06-05 08:51:39.230 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter {"Exchange":"Binance","Symbol":"ENJBTC","MinutesPerCandle":15}
2018-06-05 08:51:39.715 INFO Stockly.Services.QuoteService.QuoteHandler Received quote request for ENJBTC and retrived 1000 candles
2018-06-05 08:51:39.774 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter Serialized Message Body:
2018-06-05 08:51:39.777 INFO Stockly.Services.Messaging.Common.Extensions.MessageBodyWriter BinanceRPXBTC15
2018-06-05 08:51:39.824 ERROR NServiceBus.RecoverabilityExecutor Moving message 'f095da8a-e830-4873-8fa0-a8f200719739' to the error queue 'error' because processing failed due to an exception:
NServiceBus.MessageDeserializationException: An error occurred while attempting to extract logical messages from incoming physical message f095da8a-e830-4873-8fa0-a8f200719739 ---> Newtonsoft.Json.JsonReaderException: Unexpected character encountered while parsing value: <. Path '', line 0, position 0.
at Newtonsoft.Json.JsonTextReader.ParseValue()
Here is the configuration.
public static EndpointConfiguration ConfigureSerialization(this EndpointConfiguration endpointConfiguration)
{
var serialization = endpointConfiguration.UseSerialization<NewtonsoftSerializer>();
serialization.ContentTypeKey("NewtonsoftJson");
var settings = new JsonSerializerSettings
{
TypeNameHandling = TypeNameHandling.Auto,
Converters =
{
new IsoDateTimeConverter
{
DateTimeStyles = DateTimeStyles.RoundtripKind
}
}
};
serialization.Settings(settings);
endpointConfiguration.RegisterMessageMutator(new MessageBodyWriter());
var externalNewtonsoftJson = endpointConfiguration.AddDeserializer<NewtonsoftSerializer>();
externalNewtonsoftJson.ContentTypeKey("NewtonsoftJson");
return endpointConfiguration;
}
Any idea why this might be happening and how I can stop this from occurring?
P.S. at the moment I am using the LearningTransport.
This turned out to be some left over messages from previous test runs that still used xml as the serialization format. Clearing the input queue solved the issue.
More details: https://github.com/Particular/NServiceBus/issues/5181#issuecomment-396141572

RabbitMQ: Is delivery-mode part of the firehose notification format?

I have read http://www.rabbitmq.com/firehose.html and managed to trace some messages into a queue. I was looking to find out the "delivery-mode" (Non-persistent (1) or persistent (2).) of the messages. However, I can't see it in the firehose notification format. Is it supposed to be there?
Example:
Properties
headers:
exchange_name: myresults
routing_keys:
properties:
headers:
x-received-from:
uri: amqp://obscured1.net/%2F
exchange: myresults
redelivered: false
cluster-name: rabbit#obscured2.net
node: rabbit#b7
vhost: /
connection: rabbit#b7.3.351.0
channel: 1
user: none
routed_queues: myresults-c-v2
Payload: {.............}
Delivery mode is one of the content properties (a.k.a. message properties, basic properties).

Not able to set header to AMQP Message using MessageProperties

The below code shows how I am setting header and message type to AMQP message.
MessageProperties properties = new MessageProperties();
properties.setHeader("KEY", "HOUSE");
properties.setContentType(MessageProperties.CONTENT_TYPE_JSON);
Message message = new Message("1234567;Branch A;SALES;3000.50;Pending approval".getBytes(), properties);
rabbitTemplate.sendAndReceive("", QUEUE_NAME, message);
After sending the message in the queue, the message is received by Transformer.
#Transformer(inputChannel = "inboundChannel", outputChannel = "toutboundChannel")
public Property buildProperty(Message<String> property){
LOGGER.info("message received :: HEADERS: {}, PAYLOAD :{}", property.getHeaders(), property.getPayload());
....
}
In the logs, the header "KEY: HOUSE" is missing and even the message type is not JSON and "text/plain" instead.
LOGS:
[SimpleAsyncTaskExecutor-1] INFO com.demo.maven.spring.integration.endpoint.TransformerRequestBuilder - message received :: HEADERS: {amqp_receivedRoutingKey=mobile.queue, amqp_deliveryTag=2, amqp_replyTo=amq.rabbitmq.reply-to.g2dkABByYWJiaXRAbG9jYWxob3N0AAAW9QAAAAAD.tTIFOS2gsM7qIlGYaybfrg==, amqp_deliveryMode=PERSISTENT, amqp_redelivered=true, id=399dda4f-4ba1-7cf4-2310-03dbfbac82b6, contentType=text/plain, timestamp=1421649922840}, PAYLOAD :1234567;Branch A;SALES;3000.50;Pending approval
MessagePropertiesBuilder class is for that.
By default Spring Integration AMQP Inbound Endpoint (AmqpInboundChannelAdapter and AmqpInboundGateway) maps only standard AMQP headers. That's is a default behaviour of DefaultAmqpHeaderMapper. To accept any user-specofic headers you should inject AmqpHeaderMapper (setHeaderMapper) to that inbound endpoint with an option setRequestHeaderNames("*"). Or provide full list of names of desired custom headers.
Re. contentType=text/plain: I think something between AMQP Inbound Endpoint and that #Transformer(inputChannel = "inboundChannel" overrides the received from AMQP contentType header. Because RabbitTemplate doesn't do that, if you send Message not any other Object. Please, share DEBUG logs for the org.springframework.integration category for the message receiver. Of course we need that part of logs, when you receive message till that #Transformer
This will work, you have to build the messageproperties correctly.
MessageProperties properties = new MessageProperties();
properties.builder()
.contentType(MediaType.APPLICATION_JSON)
//headers here
.headers(Map<String, Object>)
.build();