Iot Hub - default event hub receive same message twice - azure-iot-hub

I'm having APi Service that handle some information from my device. After that i use default Iot-HUB SDK that allows me to send data into Iot-Hub. In my event hub I usually get data that I send more than once. Is there any options to see what it happens ? Maybe some extra settings that to retransmission or something that send messages more than once from my web api service ?

I had the same problem with my code. I was sending messages to an iothub using an Azure function. I had the message sending time trigger as a variable. When sending messages in shorter frequencies (i.e. messages that are sent each second) some of these messages are duplicated.
By changing the message protocol it solved. Given below is the corrected code,
DeviceClient deviceClient = DeviceClient.CreateFromConnectionString(connectionString, TransportType.Http1);

Related

Forward redis pubsub message to specific client

I'm working on a library for interacting with the Discord API. My current setup is:
A gateway, each handling x amounts of shards - so that I can spin up as many of these as I like to scale well. These gateways publish events received to a redis message queue.
A client, which subscribes to the message queue, and responds to events received.
However, there are some scenarios - working with message components - where I want a specific client to handle events related to that message. This client will then use the node.js event emitter to emit an event in itself which is then received by a 'collector' in my code.
Does anyone have any recommendations how I might stop other clients from picking up the event from the message queue, so that only this specific client picks it up? Is it possible for a subscriber to 'read' an event before it like accepts it? As then all clients could read an event to see if it like matches a list of events its waiting for?

Azure IoT Edge OPC Publisher message encoding

I want to send telemetry data from Azure iot edge device to IoTHub through OPC publisher module.
OPC publisher can be configured to encode the message either Json ("--me=Json") or Uadp ("--me=Uadp") before sending.
OPC Publisher parameters
https://github.com/Azure/Industrial-IoT/blob/main/docs/modules/publisher-commandline.md
So I configured my edge device to send the message in uadp message encoding format as its compact and compressed , However When I monitor the message received to IoTHub, its unreadable.
Message monitoring in IoTHub
Any one can help how we can decode the uadp message to readable format in IoTHub so I can process it in Azure stream analytics
Azure IoTHub messages will be encoded as per the encoding type set and saved. To decode the messages you use the "Azure Function" This can be triggered directly from the IoT-Hub. Please see the discussion on similar ask and see if it helps: https://learn.microsoft.com/en-us/answers/questions/230228/iot-hub-message-routing-received-json-message-body.html
To decode the message use the "Function App". This can be triggered directly from the IoT-Hub.
Add a consumer under "built in endpoints" -> "Consumer groups".
Under IoT-Hub message routing create a new route as "Endpoint: events" and "Data-source: Device telemetry messages".
When you create a new function use template "IoT Hub (event hub).
"event-hub-connection" was autmatically filled in. Under "event Hub-consumer..." fill in the consumer-group you created.
Then create all the rest to decode the message and write it to the place you want.

How to connect à mass transit consumer to an exchange created by a different application

I'm using Masstransit with RabbitMq to communicate between two web applications .net core.
In the publisher application I publish a message to an exchange 'producer'.
rabbitConfigurator.Message<TMessage>(x => x.SetEntityName("producer"));
In the same application I have a consumer-A of said messages and that works fine (the consumer has an exchange and a queue as recommended by rabbit/masstransit connected to the producer exchange)
rabbitConfigurator.ReceiveEndpoint("consumer-A", x =>
{
x.Consumer<TConsumer>(context);
x.Bind("producer");
});
In a second application I'm trying to setup another consumer-B of the same message type connected to the exchange 'producer'.
rabbitConfigurator.ReceiveEndpoint("consumer-B", x =>
{
x.Consumer<TConsumer>(context);
x.Bind("producer");
});
However messages destined for this second application are getting sent to a skipped queue. From what I can see this second consumer is correctly configured in RabbitMq though.
I can't see what I'm missing.
Edit: In the producing application I can also successfully receive messages in a second consumer. But from another web application it doesn't work - perhaps something to do with the fact that there's a differetn connection/channel ?
Messages sent to the producer exchange should be in a format that can be deserialized by MassTransit. If they aren't, you'll need to add a message deserializer which can support the message type. If it is application/json then you'll need to add the RawJsonMessageDeserializer to the receive endpoint.
If the messages are in the correct format, verify that you have a consumer on the receive endpoint that can consume that message type. Message types must match entirely, including namespace, to be consumed. More details are available in the documentation.

Acknowledging telegram.org server responses

The telegram documentation states:
Receipt of virtually all messages (with the exception of some purely
service ones as well as the plain-text messages used in the protocol
for creating an authorization key) must be acknowledged. This requires
the use of the following service message (not requiring an
acknowledgment):
msgs_ack#62d6b459 msg_ids:Vector long = MsgsAck;
This thread alludes to sending acks back to the server but not the mechanism by which those acks are sent. I attempted sending a MsgsAck and a msgs_ack to the server but they failed because those are data types, not constructors (methods). This leads me to two questions:
How does a telegram client send acks back to the server? (both individually and as part of a method call)
How does a telegram client differentiate between server responses that require an ack and those who don't? (it appears responses that include a req_msg_id require an ack, but I'd like confirmation)
The simple way to go about this is:
1) accumulate the msg_ids that you receive for from the server - those that need to be acknowledged as indicated in the documentation: these are all content related messages, not service messages
2) Every time you want to send new messages to the server, you could include your accumulated acknowledgment messages in a message container along with the messages you intend to send.
3) If you have accumulated msg_ids to be acknowledged for over a period say X minutes, without an opportunity to clear them via step 2) above, then you can simply send an acknowledgment message back to telegram wit the list of msg_ids to be acknowledged.
To send an acknowledgement use this:
msgs_ack#62d6b459 msg_ids:Vector<long> = MsgsAck;

Clarification on WSO2 ESB in-sequence and main sequence

I understand ESB has in-sequence, out sequence and fault sequence, Is in-sequence same as main sequence ?
Also I would like to know if we define receive sequence in a endpoint will it override default behaviour and response is handled by specified received sequence ? Will response handled by default sequence if received sequence is not specified explicitly ?
Most of the WSO2 ESB examples in internet are based on proxy service, I would like to understand how sequence can be used without proxy service, Can you please introduce me to a such tutorial ?
Triggering Messages
Messages come into the ESB through the following triggers:
A proxy service receives messages that have been sent to a specific endpoint.
A task injects a message into the ESB at a scheduled interval.
A REST API call sends a message to the ESB.
When the ESB receives a message, it sends it either to a proxy service or to the Main sequence for handling. The proxy or sequence is configured with message mediation, which controls how the message will be transformed, filtered, forwarded, etc.
To trigger messages in the ESB, see the following topics:
Creating APIs
Working with Proxy Services
Working with Tasks
Using REST
Source = https://docs.wso2.com/display/ESB481/Triggering+Messages
About the Main and Fault Sequences
A mediation configuration holds two special sequences named main and fault. All messages that are not destined for Proxy Services are sent through the main sequence. By default, the main sequence simply sends a message without mediation, so to add message mediation, you add mediators and/or named sequences in the main sequence.
By default, the fault sequence will log the message, the payload, and any error/exception encountered, and the drop mediator stops further processing. You should configure the fault sequence with the correct error handling instead of simply dropping messages. For more information, see Error Handling.
Source = https://docs.wso2.com/display/ESB481/Mediation+Sequences#MediationSequences-mainSequence
Also I would like to know if we define receive sequence in a endpoint will it override default behaviour and response is handled by specified received sequence ? Will response handled by default sequence if received sequence is not specified explicitly ?
Correct , in a proxy though , and the default behaviour is to send to "out sequence"
I am also a beginner at this , just know what I know through (a lot of) trial and error ;)
Ok so assuming you have a default offset of 0 , you're ESB instance should have 2 default transports/ports :
HTTP = 8280
HTTPS = 8243
So , any message sent to these ports will reach the main sequence , UNLESS , they are service specific endpoints, so for example , for a soap message with endpoint :
http://localhost:8280
this will reach the default main sequence , and the following
https://localhost:8243/services/yourProxyService ,
will got to the in sequence of the yourProxyService.
Also , in [esb_home]/repository/conf/log4j.properties , set/uncomment the following lines :
log4j.logger.httpclient.wire.header=DEBUG
log4j.logger.httpclient.wire.content=DEBUG
log4j.category.org.apache.synapse=DEBUG ,
this should show you much more info in the log and make it easier to know which sequence you are in..
feel free to ask me other stuff , cool