You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Martin Kuhn <ma...@gmx.at> on 2009/02/02 12:48:28 UTC

Running a Server inside SMX4 (mainframe connection server)

HI,

I've to integrate the callability of SMX4 from a mainframe.
This means that I have to run a server inside SMX which is callable from the
mainframe

The process would be: 
1) Some ESB component (which I have to provide) starts the server process
(which connects itself to a middleware).
2) Then the server process is callable from the mainframe and has a defined
entry point where the ESB stuff can be executed
3) When the mainframe calls the ESB I would like to call a servicemix-bean
in a synchronous way and pass the result back to the mainframe

I would want a really SIMPLE solution. Is it possible to define the
following peace of code in a simple bean? When I receive a host call, I
would want create a SMX MessageExchange which calls the corresponding
servicemix-bean (sync). Than I could pass the result of the service back to
the mainframe.

I already tried to start the server in an usual servicemix-bean but the SMX
behaviour was strange (when I deployed the SA after SMX start the simple
bean approach worked -> when I had the SA already deployed when SMX starts
the SMX startup hangs)


Maybe to make it a little bit more transparent -> here is a sample code
fragement I have to execute as server process in SMX
In the (xml) string (sServiceRequest) I receive  the information which I
need to know to call the corresponding service in SMX.

Code fragment for receiving mainframe calls:


Broker broker = new Broker(brokerID, "JavaServer");
BrokerService bService = new BrokerService(broker, serverAddr);

// Declare one Message object to capture an incoming message and to
// hold the reply
BrokerMessage bMessage;
try {
        bService.register();

        // listen for new connections
        boolean loop = true;

        while (loop) {
                try {
                        bMessage = bService.receive();
               
                // here an xml Service request comes in from mainframe
                        String sServiceRequest = new
String(bMessage.getMessage());
                        // Perform some logic in the ESB world (message
exchange in a synchronous way, and so on)
                        // String resultOfEsbLogic= ....
						
                       
                        bMessage.setMessage(resultOfEsbLogic);
                        bMessage.reply(new BrokerMessage(msg));
                } catch (BrokerException bE) {
                ..
                        }
                }
        }
        // deregister and logoff
        bService.deregister();
        broker.logoff();
        broker.disconnect();
} catch (BrokerException bE) {
...
}

I did a post already
(http://cwiki.apache.org/SM/discussion-forums.html#nabble-td21584515|a21584515)
but I'm really in doubt what I have to do


TIA,
Martin
-- 
View this message in context: http://www.nabble.com/Running-a-Server-inside-SMX4-%28mainframe-connection-server%29-tp21788302p21788302.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Running a Server inside SMX4 (mainframe connection server)

Posted by Martin Kuhn <ma...@gmx.at>.

Gert Vanthienen wrote:
> 
> Very strange.   Have you tried with DEBUG logging to see if that
> changes things or gives you any additional feedback?
> 
> If you're deploying in SMX4, you can probably just create an OSGi
> bundle and create the service through a Spring configuration file in
> META-INF/spring.You can get a reference to the NMR using Spring DM
> (<osgi:reference id="nmr"
> interface="org.apache.servicemix.nmr.api.NMR" /> and inject that into
> you connector bean to interact directly with the NMR, avoiding JBI
> packaging and classloading entirely.
> 

Testing:
I did testing to pin down what's going on -> here my steps

working with SMX4 (fuse-esb-4.0.0.3 -> windows xp prof)
-> removing data directory
-> cleaning deploy directory (only activemq-broker.xml is present)
-> starting SMX with debug option
-> console -> switch to log  -> set Log Level to DEBUG
-> deploying of my mainframe communication SA
(merkur.esb.host.communication.sa-1.0-SNAPSHOT.zip)

Then I tried to call SMX from mainframe (with NO success)

I switched to OSGI console and saw that my SA was in state "Active".

The I tried to stop it. After I executed the command the console was frozen.
I attached the log to this post (from the moment when my SA was deployed). I
saw no irregularities.

After a time the component is callable from the mainframe. But the console
is still frozen. Also when I try to deploy another SA it has no effect. I
see nothing in the log file. 

>From my point of view. For any reason: the functionality of the mainframe
server part disturbs SMX. But I've no idea what I can do... :-(


To your advice to create an OSGi bundle
I'm not really an expert in OSGI. So I think it would be a pain to try this
until it works (although the whole SMX stuff I did was not easy and
painful). Until now I work with maven and this hides the whole OSGI part.
When I've no other option I would spend the time. But the mainframe
connection part works perfectly outside of SMX. It is (again) really
frustrating to spend so much time to get all parts under a common system.

TIA
Regards,
Martin


http://www.nabble.com/file/p21807638/smxlog.txt smxlog.txt 
-- 
View this message in context: http://www.nabble.com/Running-a-Server-inside-SMX4-%28mainframe-connection-server%29-tp21788302p21807638.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Running a Server inside SMX4 (mainframe connection server)

Posted by Gert Vanthienen <ge...@gmail.com>.
Martin,

Very strange.   Have you tried with DEBUG logging to see if that
changes things or gives you any additional feedback?

If you're deploying in SMX4, you can probably just create an OSGi
bundle and create the service through a Spring configuration file in
META-INF/spring.You can get a reference to the NMR using Spring DM
(<osgi:reference id="nmr"
interface="org.apache.servicemix.nmr.api.NMR" /> and inject that into
you connector bean to interact directly with the NMR, avoiding JBI
packaging and classloading entirely.

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/2/2 Martin Kuhn <ma...@gmx.at>:
>
>
> Gert Vanthienen wrote:
>>
>> I don't see any real reason why your approach would not work.  Running
>> this server connection inside a servicemix-bean POJO should work just
>> fine, I think.  Perhaps something is wrong in the initialization order
>> of thing.  You could fine-tune that by using the @PostConstruct and
>> @PreDestroy annotations.  When the container is hanging at startup,
>> could you take a look at the threads through JMX or take a thread to
>> figure out what it is waiting for?
>>
>
> Gert,
>
> I put the initialization of the server in a @PostConstruct marked method. I
> see in the log
> file that the server process is initialized.
>
> Nevertheless, when I depoy the SA  it doesn't work. When I do a new start of
> the component via the osgi console (of course after stopping) the
> communication between mainframe and SMX4 works.
>
> The server process uses threads to handle incoming calls from the mainframe.
> Could this be the reason for problems?
>
> Also, it seems that other components (SA's) are influenced when the SA
> containing the server process is deployed.
>
> e.g. first deploying the SA which contains the server process.
> -> then deploying other components (SA's) -> the SA's are not callable -> I
> see in the console that the have only a status "Installed" and I'm not able
> to start the components
> There are also no error entries in the log.
>
> Can you imagine another (simple) solution to start the server process inside
> SMX4?
>
> TIA
> Martin
> --
> View this message in context: http://www.nabble.com/Running-a-Server-inside-SMX4-%28mainframe-connection-server%29-tp21788302p21789695.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>

Re: Running a Server inside SMX4 (mainframe connection server)

Posted by Martin Kuhn <ma...@gmx.at>.

Gert Vanthienen wrote:
> 
> I don't see any real reason why your approach would not work.  Running
> this server connection inside a servicemix-bean POJO should work just
> fine, I think.  Perhaps something is wrong in the initialization order
> of thing.  You could fine-tune that by using the @PostConstruct and
> @PreDestroy annotations.  When the container is hanging at startup,
> could you take a look at the threads through JMX or take a thread to
> figure out what it is waiting for?
> 

Gert,

I put the initialization of the server in a @PostConstruct marked method. I
see in the log
file that the server process is initialized.

Nevertheless, when I depoy the SA  it doesn't work. When I do a new start of
the component via the osgi console (of course after stopping) the
communication between mainframe and SMX4 works.

The server process uses threads to handle incoming calls from the mainframe.
Could this be the reason for problems?

Also, it seems that other components (SA's) are influenced when the SA
containing the server process is deployed. 

e.g. first deploying the SA which contains the server process.
-> then deploying other components (SA's) -> the SA's are not callable -> I
see in the console that the have only a status "Installed" and I'm not able
to start the components 
There are also no error entries in the log.

Can you imagine another (simple) solution to start the server process inside
SMX4?

TIA
Martin
-- 
View this message in context: http://www.nabble.com/Running-a-Server-inside-SMX4-%28mainframe-connection-server%29-tp21788302p21789695.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.


Re: Running a Server inside SMX4 (mainframe connection server)

Posted by Gert Vanthienen <ge...@gmail.com>.
Martin,

I don't see any real reason why your approach would not work.  Running
this server connection inside a servicemix-bean POJO should work just
fine, I think.  Perhaps something is wrong in the initialization order
of thing.  You could fine-tune that by using the @PostConstruct and
@PreDestroy annotations.  When the container is hanging at startup,
could you take a look at the threads through JMX or take a thread to
figure out what it is waiting for?

Regards,

Gert Vanthienen
------------------------
Open Source SOA: http://fusesource.com
Blog: http://gertvanthienen.blogspot.com/



2009/2/2 Martin Kuhn <ma...@gmx.at>:
>
> HI,
>
> I've to integrate the callability of SMX4 from a mainframe.
> This means that I have to run a server inside SMX which is callable from the
> mainframe
>
> The process would be:
> 1) Some ESB component (which I have to provide) starts the server process
> (which connects itself to a middleware).
> 2) Then the server process is callable from the mainframe and has a defined
> entry point where the ESB stuff can be executed
> 3) When the mainframe calls the ESB I would like to call a servicemix-bean
> in a synchronous way and pass the result back to the mainframe
>
> I would want a really SIMPLE solution. Is it possible to define the
> following peace of code in a simple bean? When I receive a host call, I
> would want create a SMX MessageExchange which calls the corresponding
> servicemix-bean (sync). Than I could pass the result of the service back to
> the mainframe.
>
> I already tried to start the server in an usual servicemix-bean but the SMX
> behaviour was strange (when I deployed the SA after SMX start the simple
> bean approach worked -> when I had the SA already deployed when SMX starts
> the SMX startup hangs)
>
>
> Maybe to make it a little bit more transparent -> here is a sample code
> fragement I have to execute as server process in SMX
> In the (xml) string (sServiceRequest) I receive  the information which I
> need to know to call the corresponding service in SMX.
>
> Code fragment for receiving mainframe calls:
>
>
> Broker broker = new Broker(brokerID, "JavaServer");
> BrokerService bService = new BrokerService(broker, serverAddr);
>
> // Declare one Message object to capture an incoming message and to
> // hold the reply
> BrokerMessage bMessage;
> try {
>        bService.register();
>
>        // listen for new connections
>        boolean loop = true;
>
>        while (loop) {
>                try {
>                        bMessage = bService.receive();
>
>                // here an xml Service request comes in from mainframe
>                        String sServiceRequest = new
> String(bMessage.getMessage());
>                        // Perform some logic in the ESB world (message
> exchange in a synchronous way, and so on)
>                        // String resultOfEsbLogic= ....
>
>
>                        bMessage.setMessage(resultOfEsbLogic);
>                        bMessage.reply(new BrokerMessage(msg));
>                } catch (BrokerException bE) {
>                ..
>                        }
>                }
>        }
>        // deregister and logoff
>        bService.deregister();
>        broker.logoff();
>        broker.disconnect();
> } catch (BrokerException bE) {
> ...
> }
>
> I did a post already
> (http://cwiki.apache.org/SM/discussion-forums.html#nabble-td21584515|a21584515)
> but I'm really in doubt what I have to do
>
>
> TIA,
> Martin
> --
> View this message in context: http://www.nabble.com/Running-a-Server-inside-SMX4-%28mainframe-connection-server%29-tp21788302p21788302.html
> Sent from the ServiceMix - User mailing list archive at Nabble.com.
>
>