You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Rajith Attapattu <ra...@gmail.com> on 2006/11/25 16:56:16 UTC

Client code design

Hi Folks,

I have a few reservations about the way the client code is designed right
now.
There is very tight coupling btw the JMS interfaces and the AMQP code.
Making changes or improvements is very difficult as you can easily break
something and it is also error prone.

For example consider the following method,

    public TopicPublisher createPublisher(Topic topic) throws JMSException
    {
        return (TopicPublisher) createProducer(topic);
    }

This method throws a ClassCastException bcos the
o.a.q.c.BasicMessageProducer doesn't implement TopicPublisher ( neither
MessageSender).
So the current way to do is to get o.a.q.c.BasicMessageProducer to implement
these interfaces, which is not good IMO.
This will unnecessarily complicate the BasicMessageProducer code and will
make  readability, debugging and maintaining code difficult.

Instead as I proposed before under "AMQP client API" thread, lets try to
separate these two layers for the sake of good design practices.
Lets keep the BasicMessageProducer code clean and simple (AMQP specific).

Then lets have concrete implementations of JMS interfaces that proxy the
functionality to the AMQP layer.
I will start re-factoring as I start fixing the JMS issues.
The lines btw the AMQP API and AMQP Implementation may be a bit blur, until
we get things right, but still it's better than what we have now.

For example


-----------------------------------------------------------------
                                 JMS API

-----------------------------------------------------------------
                     JMS Implementation

------------------------------------------------------------------
                      AMQP API
           -----------------------------------------------------------------
                     AMQP Implementation
            ---------------------------------------------------------------

Regards,
Rajith

Re: Client code design

Posted by Robert Greig <ro...@gmail.com>.
On 25/11/06, Rajith Attapattu <ra...@gmail.com> wrote:

> This method throws a ClassCastException bcos the
> o.a.q.c.BasicMessageProducer doesn't implement TopicPublisher ( neither
> MessageSender).
> So the current way to do is to get o.a.q.c.BasicMessageProducer to implement
> these interfaces, which is not good IMO.

The approach that has been taken with other JMS 1.0.2 interfaces is to
create an adapter. See QPID-58 for example. BasicMessageProducer
implements javax.jms.MessageProducer which is a JMS 1.1 interface.

RG