ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Problem in Java Compute Node connect with hibernate

Post new topic  Reply to topic Goto page 1, 2  Next
 Problem in Java Compute Node connect with hibernate « View previous topic :: View next topic » 
Author Message
mahesh2069
PostPosted: Wed Jun 26, 2013 6:53 am    Post subject: Reply with quote

Centurion

Joined: 26 Jun 2013
Posts: 103

Hi
I want to use hibernate to maintain cache in java compute node,with help of Session,and second level cache.

For using hibernate I have to build the path,I will add .jar file of hibernate to library ,and I when what to use method of session object it do not work properly. Here WMB 8.0 show errors.

I unable to use Session object.Help me how can I use add external .jar to our Message Project in WMB8.0

When I use Session Object error has been raised.


Code:


import java.util.Map;

import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.*;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;


import com.mss.dto.Person;

public class HibernetConnectionTest_mf_JavaCompute extends MbJavaComputeNode {

   public void evaluate(MbMessageAssembly contact admin) throws MbException {
      MbOutputTerminal out = getOutputTerminal("out");
      MbOutputTerminal alt = getOutputTerminal("alternate");

      MbMessage inMessage = contact admin.getMessage();

      // create new message
      MbMessage outMessage = new MbMessage();
      MbMessageAssembly outAssembly = new MbMessageAssembly(contact admin,
            outMessage);
         
      try {
         // optionally copy message headers
         copyMessageHeaders(inMessage, outMessage);

         // ----------------------------------------------------------
         // Add user code below
      //   MbGlobalMapSessionPolicy sespol=new MbGlobalMapSessionPolicy(600);
         /*MbGlobalMap mbmap=MbGlobalMap.getGlobalMap("myMapp");
         mbmap.put(1,"Mahesh");
         mbmap.put(2,"Sai");   
         
         String data=(String)mbmap.get(1);
         
         System.out.println("Data of key --> 1 is \t"+data);   
         MbElement outRoot=outAssembly.getMessage().getRootElement();
         MbElement parser=outRoot.createElementAsLastChild(MbXMLNSC.XML_DECLARATION);
         MbElement parent=parser.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,"Data",data);
         */
         Session session = null;
         try
         {
            
         Configuration cfg=new Configuration();
         cfg.configure();
          SessionFactory sessionFactory=cfg.buildSessionFactory();
         -- HERE I GOT ERROR WHILE GETTING SESSION OBJECT 
         [b] session =sessionFactory.openSession();[/b]
         
         Person person = new Person();
         System.out.println("Inserting Record");
         
         [b]Transaction tx = session.beginTransaction();[/b]
         System.out.print(person);
         person.setId(1);
         person.setName("Mahesh");
         System.out.print("\n"+person.getId()+"\n");
         [b]session.save(person);[/b]
         
      [b]   tx.commit();[/b]
         System.out.println("Done");
      }
         catch (Exception e) {
         System.out.println(e.getMessage());
      }
         finally {
            session.close();
      
   }
         }
      catch (Exception e) {
         System.out.println(e);
         // TODO: handle exception
      
         MbElement outRoot=outAssembly.getExceptionList().getRootElement();
         //MbElement parser=outRoot.createElementAsLastChild(MbXMLNSC.XML_DECLARATION);
         
           //MbUserException mbException=new MbUserException(e.getClass(),null,e.getMessage(),null,null,null);
       MbRecoverableException mbException=new MbRecoverableException("HibernetConnectionTest_mf_JavaCompute","evaluate",inMessage.getRootElement().getName(),"",e.toString(),null);
       throw mbException;
         //MbElement exceList=outRoot.createElementAsLastChild(MbElement.TYPE_NAME_VALUE,null,mbException);
      }
      finally
      {
         System.out.println("Finally blcok");
      }
   

         // End of user code
         // ----------------------------------------------------------

         // The following should only be changed
         // if not propagating message to the 'out' terminal
         out.propagate(outAssembly);

      }

   
   


   public void copyMessageHeaders(MbMessage inMessage, MbMessage outMessage)
         throws MbException {
      MbElement outRoot = outMessage.getRootElement();

      // iterate though the headers starting with the first child of the root
      // element
      MbElement header = inMessage.getRootElement().getFirstChild();
      while (header != null && header.getNextSibling() != null) // stop before
                                                   // the last
                                                   // child
                                                   // (body)
      {
         // copy the header and add it to the out message
         outRoot.addAsLastChild(header.copy());
         // move along to next header
         header = header.getNextSibling();
      }
   }

}
Back to top
View user's profile Send private message
mqjeff
PostPosted: Wed Jun 26, 2013 7:07 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Broker is not a JEE application server, and Broker flows should ideally be built to be stateless, thus outside of a session.

That doesn't mean that what you are trying to do can't work, nor even that it shouldn't be done. It just means that it's not the usual way to do things, and you should think about it.

You've identified the point in your code where you are receiving an error.

You haven't said what the error is.

Also, you probably don't want to add hibernate jar files to your library and deploy them that way. You probably want to deploy them to a fixed location on the broker server, and add a JavaClassloader configurable service that points to that location.

That location should not be anywhere that is already being loaded by an existing Broker classloader.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Jun 26, 2013 7:35 am    Post subject: Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

Why would you want to use Hibernate rather than the in-built broker functionality to "maintain cache in java compute node"?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
mahesh2069
PostPosted: Wed Jun 26, 2013 9:01 am    Post subject: Problem in use MbGlobalMap Reply with quote

Centurion

Joined: 26 Jun 2013
Posts: 103

Hi

For maintain cache here I use MbGlobalMap.But when I use want to instance of MbGlobalMap ,JCN node through Exception.

I mention that code also in posted code..But I comment it.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Jun 26, 2013 9:17 am    Post subject: Re: Problem in use MbGlobalMap Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

mahesh2069 wrote:
Hi

For maintain cache here I use MbGlobalMap.But when I use instance of MbGlobalMap ,JCN node through Exception.

I mention that code also in posted code..But I comment it


What exception do you get?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
mahesh2069
PostPosted: Wed Jun 26, 2013 10:12 am    Post subject: Exception Details when I use MbGlobalMap. Help me to resolve Reply with quote

Centurion

Joined: 26 Jun 2013
Posts: 103

Exception details When I use MbGlobalMap

cause :MB Recoverable Exception
class name: MB Cache Manager
File name : MB Cache Manager(id=1744)
Method Name : getConnection(id=1483)
Message Source : Bips MSGs
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Jun 26, 2013 10:16 am    Post subject: Re: Exception Details when I use MbGlobalMap. Help me to res Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

mahesh2069 wrote:
Exception details When I use MbGlobalMap

cause :MB Recoverable Exception
class name: MB Cache Manager
File name : MB Cache Manager(id=1744)
Method Name : getConnection(id=1483)
Message Source : Bips MSGs


These are not the full details, but it looks like you have not followed the step-by-step instructions to configure the Global Cache.

When you deployed the Global Cache sample, did it work for you?

http://publib.boulder.ibm.com/infocenter/wmbhelp/v8r0m0/index.jsp?topic=%2Fcom.ibm.etools.mft.samples.coordinated_request_reply.doc%2Fdoc%2Fglobalcachesample.htm
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
MikeOliverAZ
PostPosted: Wed Jul 10, 2013 4:43 pm    Post subject: Hibernate in Java Compute Node Reply with quote

Apprentice

Joined: 10 Jul 2013
Posts: 47

Mahesh,

I too want to do as you do, so would be interested in what you found and did to accomplish it.

Lancelotinc, I am sure Mahesh has his own reasons, but my reasons are two fold. One is that in our Java Compute node we already have entities maintained by Hibernate in a separate application from the Broker application that is primarily used for Orchestration of Atomic Services. The second reason is that the new GlobalCache doesn't seem as mature or as automatic as the L2 Cache we get with Hibernate, especially Hibernate L2 Cache backed by Oracle Coherence.
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Thu Jul 11, 2013 3:20 am    Post subject: Re: Hibernate in Java Compute Node Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

MikeOliverAZ wrote:
Mahesh,

I too want to do as you do, so would be interested in what you found and did to accomplish it.

Lancelotinc, I am sure Mahesh has his own reasons, but my reasons are two fold. One is that in our Java Compute node we already have entities maintained by Hibernate in a separate application from the Broker application that is primarily used for Orchestration of Atomic Services. The second reason is that the new GlobalCache doesn't seem as mature or as automatic as the L2 Cache we get with Hibernate, especially Hibernate L2 Cache backed by Oracle Coherence.


You can have your own opinion, but most WMB developers who use the GlobalCache would not agree with your assessment that GlobalCache is not mature. The GlobalCache is built on eXtremeScale technology which has been around for seven years now in various forms. I use GlobalCache in all my flows and have not had a lick of trouble with it.

If you want to use Hibernate, put your application on WAS not WMB. People use Singleton pattern for atomicity, which is a whole more light-weight than Hibernate.

If you are in the mindset that you want WMB runtime to be your application container like a WAS instance, then you will likely be in for alot of trouble from a number of different angles; not the least of which is your lack of use of the power contained within the WMB runtime. Simply throwing a bunch of Java code in a JCN does not leverage the power that WMB provides. WMB licenses are expensive. Java applications containers are free. Why waste a bunch of money on WMB license just to put Hibernate in a JCN?

It seems you are new to developing real applications using WebSphere Message Broker. What has been your experience? How many WMB applications are in production that you have written? If your typical flow is an MQInput to a JCN to a MQOuput/MQReply, your better off writing Message Driven Beans on WAS.
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
MikeOliverAZ
PostPosted: Thu Jul 11, 2013 3:49 pm    Post subject: Common tactic Reply with quote

Apprentice

Joined: 10 Jul 2013
Posts: 47

Thanks, but just because I have a different opinion on a particular product doesn't mean I am a beginner. I was writing applications in broker since 2006, I wrote my first code on punched paper tape in 1970. I am lead architect on a SOA COE for a multi billion dollar corporation. Ok so I get it you dont agree with the use of Java in WMB you are not alone. We have chosen and bought the entire IBM SOA stack and tivoli stack and our Enterprise SOA is based on using WMB and BPM along with Datapower. We have many reasons for wanting to use Java in places, not because we are beginners that simply don't know as much as you.
Back to top
View user's profile Send private message Send e-mail
lancelotlinc
PostPosted: Fri Jul 12, 2013 3:12 am    Post subject: Re: Common tactic Reply with quote

Jedi Knight

Joined: 22 Mar 2010
Posts: 4941
Location: Bloomington, IL USA

MikeOliverAZ wrote:
Ok so I get it you dont agree with the use of Java in WMB you are not alone.


I use Java in just about every main flow I have. I use log4j as my logging framework.

It's not that I don't agree with using Java.

More straight to the point: Hibernate is useless in WMB when compared to the native capabilities that WMB has.

MikeOliverAZ wrote:
I am lead architect on a SOA COE for a multi billion dollar corporation.


Let's hope we can share some experiences together in a friendly way so we both learn something new.

MikeOliverAZ wrote:
We have many reasons for wanting to use Java in places, not because we are beginners that simply don't know as much as you.


I'll be the first to tell you I know very little. But what I do know, I share. Some people take a-back in how I share it. That's ok, once you get to know me, I'm not quite so abrasive.


Henry Ford said once: "You can have any color car you want, as long as its black." I say : You can write any kind of flow you want, as long as it works.


Using Hibernate in a JCN is ignoring the power that the WMB product provides.


If one of your developers came to you and said, I know we have Java in the 21st century, but I want to write my code in Pascal. What would you tell her or him?
_________________
http://leanpub.com/IIB_Tips_and_Tricks
Save $20: Coupon Code: MQSERIES_READER
Back to top
View user's profile Send private message Send e-mail
MikeOliverAZ
PostPosted: Sun Jul 14, 2013 3:30 pm    Post subject: No pissing war Reply with quote

Apprentice

Joined: 10 Jul 2013
Posts: 47

Lancealot,

There you go again, I am not ignoring anything. When we compared Oracle Coherence/Hibernate with WXS/GlobalCache we found this...

http://www.ibm.com/developerworks/websphere/library/techarticles/1212_hart/1212_hart.html This IBM article was the basis of my remark on maturity, Coherence/Hibernate L2 Cache does not have ANY of these problems.

Now we already have a Web Application running on WAS that uses Hibernate to persist our entities, we already have the licenses for Coherence. Get over it. We need those entities in our JCN. Stop trying to convince me you are right about not using hibernate, that is not helpful.

Shakespeare said it best, "me things the lady doth protesteth too much."
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Sun Jul 14, 2013 8:53 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

MikeOliverAZ -
Are you experienceing a specific issue trying to do this? Is there specific setup you have followed?
Back to top
View user's profile Send private message
MikeOliverAZ
PostPosted: Sun Jul 14, 2013 9:27 pm    Post subject: Specifics Reply with quote

Apprentice

Joined: 10 Jul 2013
Posts: 47

Jeff,

No, just planning stage and having read the message earlier in this thread I was hoping to get some guidance on what to do or not do to employ Hibernate backed by Coherence in my Java Compute Node. Not advice on whether Hibernate is a worthy choice vs. WXS/GlobalCache.

Thanks in advance.

MO
Back to top
View user's profile Send private message Send e-mail
mqjeff
PostPosted: Sun Jul 14, 2013 10:31 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

Like any other relatively heavy weight java implementation, you should use a JavaClassloader Configurable service, or perhaps more than one, to make sure you can tightly control the classloaders for specific flows.

And keep in mind when doing your planning that every ExecutionGroup is a separate JVM.

And keep in mind all of the issues of sharing objects across multiple JVMs, rather than exchanging messages that represent object data. Trying to use a serialized v1.2 of an object in a JVM that only knows about v1.1 can be tricky....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Goto page 1, 2  Next Page 1 of 2

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » Problem in Java Compute Node connect with hibernate
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.