Skip to content

Documentation to work with Activemq Artemis #286

@AndreSteenbergen

Description

@AndreSteenbergen

The standard HelloWorld sample works in multiple Amqp 1.0 brokers, I had some issues using Activemq Artemis. It was caused by artemis standard auto-creation feature. all-defaults it will create topics. When you want to work with queues you need to specify it in either broker.xml, or you can set it using Capabilities, see below. Might be good to document how to work with different brokers.

 public class SimpleAmqpTest
    {
        [Fact]
        public async Task TestHelloWorld()
        {
            Address address = new Address("amqp://guest:guest@localhost:5672");
            Connection connection = await Connection.Factory.CreateAsync(address);
            Session session = new Session(connection);
            
            Message message = new Message("Hello AMQP");

            Target target = new Target
            {
                Address = "q1",
                Capabilities = new Symbol[] { new Symbol("queue") }
            };

            SenderLink sender = new SenderLink(session, "sender-link", target, null);
            await sender.SendAsync(message);

            Source source = new Source
            {
                Address = "q1",
                Capabilities = new Symbol[] { new Symbol("queue") }
            };

            ReceiverLink receiver = new ReceiverLink(session, "receiver-link", source, null);
            message = await receiver.ReceiveAsync();
            receiver.Accept(message);

            await sender.CloseAsync();
            await receiver.CloseAsync();
            await session.CloseAsync();
            await connection.CloseAsync();
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    InfoUseful information

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions