I am preparing to develop application that connects to Azure Service Bus. For development I want use Service Bus 1.1.
I have installed localy Service Bus 1.1 and it works fine when I am connecting with package Service Bus.v1_1 ver. 1.0.5.
But as I want eventually work with Azure I prefer to use package WindowsAzure Service Bus which as I know sholud work with Service Bus 1.1.
But when I want to execute:
namespaceManager.QueueExists(queueName)
with WindowsAzure.ServiceBus ver 3.1.2 package I receive:
'System.ArgumentException' ....
The remote server returned an error: (400) Bad Request. The api-version in the query string is not supported. Either remove it from the Uri or use one of '2012-03,2012-08,2013-04,2013-07'.
Adding ?api_version=2013-07 to Uri does not helps.
However sending message to queue that exists on local SB1.1 works well (Using WindowsAzure.ServiceBys 3.1.2).
So it just applies to connections with NamespaceManager.
Could anyone has any ideas why it does not work ?
The code I use for tests:
var cs ="Endpoint=sb://mylocalmachine/ServiceBusDefaultNamespace/;StsEndpoint=https://mylocalmachine:9355/ServiceBusDefaultNamespace/;RuntimePort=9354;ManagementPort=9355";
var queueName = "AAA";
var namespaceManager = NamespaceManager.CreateFromConnectionString(cs);
var messagingFactory = MessagingFactory.CreateFromConnectionString(cs);
var ver = namespaceManager.GetVersionInfo();
if (namespaceManager.QueueExists(queueName))
{
namespaceManager.DeleteQueue(queueName);
}
namespaceManager.CreateQueue(queueName);
QueueClient client = messagingFactory.CreateQueueClient(queueName);
client.Send(new BrokeredMessage("Hello! " + DateTime.Now));
client = messagingFactory.CreateQueueClient(queueName, ReceiveMode.ReceiveAndDelete);
BrokeredMessage message = client.Receive();
if (message != null)
{
Console.WriteLine(message.GetBody<string>());
}
Console.ReadKey();
To my knowledge the WindowsAzure.ServiceBus package is not compatible with on premises Windows Service Bus. We are stuck with using the old package.
I believe the libraries are source compatible for most things, so when you DO migrate to using Azure service bus instead of on-prem, then it should be as simple as swapping out the package and changing the authentication mechanisms and connection strings and recompiling and testing.
Related
I am using Apache.NMS.AMQP library in our .netcore 5 project. We connect to Apache ActiveMQ Artemis as a middle layer for the event driven architecture using AMQP protocol.
There is no issue in consuming messages from the same amqp protocol; but when publishing to a topic, we are getting some errors.
broker URI:
failover:(amqp://localhost:5672)?transport.startupMaxReconnectAttempts=1&transport.randomize=false
Code:
var _factory = new Apache.NMS.AMQP.ConnectionFactory(_connectURI);
IConnection connection = _factory.CreateConnection(username,password);
ISession session = connection.CreateSession(AcknowledgementMode.AutoAcknowledge);
ITextMessage msg = session.CreateTextMessage(stringMessage);
var topicDestination = SessionUtil.GetTopic(session, topic);
connection.Start();`
IMessageProducer publisher = session.CreateProducer(topicDestination);
publisher.DeliveryMode = MsgDeliveryMode.Persistent;
publisher.Send(msg);
Error that I'm getting:
Message ID: xxxx:2:1:1-1 rejected, Description = org.apache.qpid.proton.amqp.UnsignedByte cannot be cast to java.lang.byte
I tried several combinations of sending the same from different methods, added Apache.NMS library on top of it as well. But still no luck.
Anyone have come across this issue?
I have used amq broker 7.10 and the issue is sorted in the broker.
I have few topics and subscriptions on google pub/sub. I created .net core application which publish and receives messages using Google.Cloud.PubSub.V1 nuget library.
Code is pretty easy:
// send a message
var result = await publisher.PublishAsync(topicName, messages);
...
// receive pending messages in loop
var response = await subscriber.PullAsync(subscriptionName, true, count);
As I see from logs publisher successfully publish a message but subscriber never receive it. Same application does not work on cloud but works on local machine. Configuration is same on both environments (my machine get access to same Pub/Sub service as production). Is it possible somehow make a diagnostics and find out what the problem is?
I am trying to connect to MQ using XMS .Net. The MQ is currently setup on the server and using IBM.WMQ I am able to connect to it. Now I want to explore the IBM XMS as it supports API so in future we can try connecting to MQ from .net full-framework or .net core clients.
Spent 2 days over the web but not able to find a full sample where this is implemented. I also don't want to install the MQ client on my local machine. Is there a way to do this? Are there any good articles available for the same?
Following link provides an overview of XMS.NET
http://www-01.ibm.com/support/docview.wss?uid=swg27024064
IBM MQ Redistributable package can be used to develop MQ .NET applications without installing the Client.You will have to use MQ v9.0.5 or above to use XMS.NET client.You can download the latest redistributable package from the following link
9.1.0 IBM MQ C and .NET redistributable client for Windows x64
If you have MQ client install then there are samples located at "MQ_INSTALL_PATH\Tools\dotnet\samples\cs\xms\simple\wmq" and following link provides a brief description about the samples
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.0.0/com.ibm.mq.xms.doc/xms_csamp.html
Following is the code sample to get a message asynchronously using Message listeners.
/// <summary>
/// Setup connection to MQ queue manager using XMS .NET
/// </summary>
private void ibmmqSetupConnection()
{
XMSFactoryFactory factoryFactory;
IConnectionFactory cf;
IDestination destination;
IMessageConsumer consumerAsync;
MessageListener messageListener;
// Get an instance of factory.
factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
// Create WMQ Connection Factory.
cf = factoryFactory.CreateConnectionFactory();
// Set the properties
cf.SetStringProperty(XMSC.WMQ_HOST_NAME, "host.ibm.com");
cf.SetIntProperty(XMSC.WMQ_PORT, 1414);
cf.SetStringProperty(XMSC.WMQ_CHANNEL, "QM.SVRCONN");
cf.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
cf.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, "QM1");
cf.SetStringProperty(XMSC.USERID, "myuserid");
cf.SetStringProperty(XMSC.PASSWORD, "passw0rd");
// Create connection.
connectionWMQ = cf.CreateConnection();
// Create session with client acknowledge so that we can acknowledge
// only if message is sent to Azure Service Bus queue
sessionWMQ = connectionWMQ.CreateSession(false, AcknowledgeMode.ClientAcknowledge);
// Create destination
destination = sessionWMQ.CreateQueue("INPUTQ");
// Create consumer
consumerAsync = sessionWMQ.CreateConsumer(destination);
// Setup a message listener and assign it to consumer
messageListener = new MessageListener(OnMessageCallback);
consumerAsync.MessageListener = messageListener;
// Start the connection to receive messages.
connectionWMQ.Start();
// Wait for messages till a key is pressed by user
Console.ReadKey();
// Cleanup
consumerAsync.Close();
destination.Dispose();
sessionWMQ.Dispose();
connectionWMQ.Close();
}
With EasyNetQ v0.63.0.448, RabbitMqClient v4.0.2 and RabbitMq server 3.6.5 when I try to create a bus like so...
bus = RabbitHutch.CreateBus(new ConnectionConfiguration()
{
Hosts = new[] { new HostConfiguration() { Host = hostName, Port = port } },
UserName = username,
Password = password,
}, x => { }).Advanced;
I'm getting the Error:
"Field Not Found 'RabbitMQ.Client.ConnectionFactory.AutomaticRecoveryEnabled'."
Is this an underlying incompatibility between easynetq and this version of Rabbit or is there a change in the API somewhere that I need to reflect?
It looks like that version of EasyNetQ is compiled against version 3.6.0 of RabbitMQ. In version 4 of RabbitMQ, AutomaticRecoveryEnabled and some other fields in ConnectionFactory were changed to properties which is a breaking change.
Until EasyNetQ is recompiled using version 4 of RabbitMQ you will have to use an older version of RabbitMQ - 3.6.5 seems to work for me.
The following call
CloudStorageAccount.Parse(<connection-string>);
returns this error:
"No valid combination of account information found."
with the connection string copied directly from the CONNECTION STRING–PRIMARY KEY field on the Azure service Bus Access Policies -> Policy blade, which looks like this:
Endpoint=sb://xxx.servicebus.windows.net/;SharedAccessKeyName=xxx;SharedAccessKey=xxx;EntityPath=xxx
I need CloudQueueClient and CloudQueue instances to do queue manipulation.
Am I missing something obvious, or is there another way to initialise CloudStorageAccount?
Update: the following syntax allows me to add a new queue using the service level (not queue level) credentials, but I'm not sure how I get from here to a CloudQueue or CloudQueueClient instance.
var queueNamespace = NamespaceManager.CreateFromConnectionString(
"Endpoint=sb://<service-account>.servicebus.windows.net/;
SharedAccessKeyName=sharedaccess;
SharedAccessKey=xxx");
The reason you're getting this error is because you're trying to use storage client library for Service Bus resources. Microsoft.WindowsAzure.Storage is the client library for Azure Storage. Queues in Azure Storage are not a Service Bus Queues.
For Service Bus queues you would need to use its client library that you can install via Nuget from https://www.nuget.org/packages/WindowsAzure.ServiceBus/.
Once you do that, you should be able to create a NamespaceManager using the following code:
var manager = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(ConnectionString);
and then you will be able to perform operations on your Service Bus Queues.
You may find this link useful as well: https://azure.microsoft.com/en-in/documentation/articles/service-bus-dotnet-get-started-with-queues/.