Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

amqp interop based example #3

Closed
wants to merge 1 commit into from

Conversation

makasim
Copy link

@makasim makasim commented Aug 11, 2017

I propose to rewrote examples using amqp interop. It has several benefits:

  • Easier to use. Single API.
  • Descriptive, clean and semantical OOP API.
  • It would work with any amqp interop compatible transport.
  • We already have transports for php-amqplib, amqp-ext, bunny.
  • Java JMS like interfaces.

We ported RabbitMQ official tutorials to amqp interop too.

@makasim
Copy link
Author

makasim commented Sep 22, 2017

@carlhoerberg could you please have a look at this?

$ch->basic_publish($msg, $exchange);
$context = (new AmqpConnectionFactory(getenv('CLOUDAMQP_URL')))->createContext();
$queue = $context->createQueue('basic_get_queue');
$queue->addFlag(AmqpQueue::FLAG_DURABLE);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how can you set a flag after the queue is declared? all queue arguments are immutable.

Copy link
Author

@makasim makasim Sep 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@carlhoerberg On a broker's side, it is indeed immutable, though if we try to declare a queue with exactly the same parameters several times the broker won't complain.

The createQueue method does not perform declaration. It creates a local queue object. There is a declareQueue method that does the job.

The queue interop is insipred by Java JMS spec and follows it. Here's the doc for create queue method: https://docs.oracle.com/javaee/7/api/javax/jms/JMSContext.html#createQueue-java.lang.String-

$ch->close();
$conn->close();
?>
$context->createProducer()->send($queue, $message);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's a producer? a channel? so you create a single channel for each publish?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's a producer?

https://docs.oracle.com/javaee/7/api/javax/jms/JMSProducer.html

The most important parts from there:

A JMSProducer is a simple object used to send messages on behalf of a JMSContext.
Instances of JMSProducer are intended to be lightweight objects which can be created freely and which do not consume significant resources. This interface therefore does not provide a close method.

a channel?

The producer is not a channel. The context is a representation of AMQP's channel.

https://docs.oracle.com/javaee/7/api/javax/jms/JMSContext.html

@makasim
Copy link
Author

makasim commented Nov 17, 2017

@carlhoerberg Is there any interest in this? Or should I close it?

@makasim
Copy link
Author

makasim commented Sep 28, 2018

@snichme could you please take a look at it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants