Windows Azure Service Bus became a powerful mechanism to distribute messages in applications that are hosted in a cloud environment or in a system that has access to internet.
When we are using this service to notify different state change, I had moments when I need to signal a state change only after a specific time interval. To be able to support this functionality we need to be able to add the message to the topic only after the specific time elapsed. This means that we need to implement a component that can store this messages for a specific time interval. We will publish this message only after the specific time interval.
A new feature was added to Windows Azure Service Bus message. This new feature give us the possibility to make a message available in the topic only from a specific time. We can forget the component that we talked some lines ago. From now, this is supported by default. We have the support to specific the time from when the message will be available – in UTC format.
Before starting using this, we need to know a very important thing. This new feature guarantee that the message will be available only after the specific time, BUT we don’t have the guaranty that the message will be available from the next second. Based on the load of our Service Bus, this message can be made available on the specific time interval or after few seconds.
In the next example we will see how we create a message (BrokeredMessage) and specific the time when it will be available on the topic.
When we are using this service to notify different state change, I had moments when I need to signal a state change only after a specific time interval. To be able to support this functionality we need to be able to add the message to the topic only after the specific time elapsed. This means that we need to implement a component that can store this messages for a specific time interval. We will publish this message only after the specific time interval.
A new feature was added to Windows Azure Service Bus message. This new feature give us the possibility to make a message available in the topic only from a specific time. We can forget the component that we talked some lines ago. From now, this is supported by default. We have the support to specific the time from when the message will be available – in UTC format.
Before starting using this, we need to know a very important thing. This new feature guarantee that the message will be available only after the specific time, BUT we don’t have the guaranty that the message will be available from the next second. Based on the load of our Service Bus, this message can be made available on the specific time interval or after few seconds.
In the next example we will see how we create a message (BrokeredMessage) and specific the time when it will be available on the topic.
// Create the message
DateTime availableFromInUTC = ...
BrokeredMessage msg = new BrokeredMessage("some content");
msg.ScheduledEnqueueTimeUtc = availableFromUTC;
// Create message sender
MessagingFactory messageFactory =
MessagingFactory.CreateFromConnectionString(connectionString);
MessageSender messageSender = messageFactory.CreateMessageSender("topic1");
// Send the message to the topic
messageSender.Send(msg);
Another great feature on Windows Azure Service Bus.
Comments
Post a Comment