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 » MbService.logError

Post new topic  Reply to topic
 MbService.logError « View previous topic :: View next topic » 
Author Message
vvssivakumar
PostPosted: Wed May 21, 2008 11:47 am    Post subject: MbService.logError Reply with quote

Newbie

Joined: 21 May 2008
Posts: 1

Im trying to write to syslog using MbService.logError as shown below,in java compute node.

MbService.logError(this,"getErrCode",Dispatch.MESSAGE_SOURCE,Dispatch.JAVA_ERR,
"JAVA API ERROR",new String[] { e.toString(),stackTrace });


Resource Bundle class:

public static class Dispatch extends ListResourceBundle
{

public static final String MESSAGE_SOURCE = Dispatch.class.getName();
public static final String JAVA_ERR = "JAVA_ERR";

private Object[][] messages = {{JAVA_ERR, "An exception occurred calling the JAVA API: exception: %1 stacktrace: %2" }};


public Object[][] getContents()
{

return messages;
}

}



my problem is ...... %1 , %2 are not resolved while writing to syslog:

[j_err_handler.J_ERR_HNDLR_JavaCompute$Dispatch:JAVA_ERR]An exception occurred calling the JAVA API: exception: %1 stacktrace: %2: JAVA API ERROR. : BMSGD5Q2_B_DV5.8827ed3e-1901-0000-0080-d3005d24e396: : 0: j_err_handler.J_ERR_HNDLR_JavaCompute: getErrCode: :


am I missing something...your suggestions will be of gr8 help to me

-Siva
Back to top
View user's profile Send private message
Featherstone
PostPosted: Wed Jan 19, 2011 4:41 am    Post subject: MBService Insert Paramters Not Recognised Reply with quote

Novice

Joined: 18 Oct 2010
Posts: 11

I'm trying to use MBService class in a Java compute node in WMB7 flow and getting strange results. In my case the %1 defined in the log message is not being replaced with the passed object item but instead with the name of the execution group that the flow is running in!

I've imported and deployed the JavaComputeNodeSample project that has an example of the MbService.logError call on the catch logic for the evaluate procedure. When I run the flow I get the following in the Windows event viewer:

( MB7BROKER.JavaComputeNodeExecutionGroup ) Java node error: '[com.ibm.broker.javacompute.samples.RegexFilterNode$RegexFilterNodeMessages:INVALID_REGEX]MB7BROKER.JavaComputeNodeExecutionGroup is not a valid regular expression.: Invalid regex'.


'MB7BROKER.JavaComputeNodeExecutionGroup' is the broker and EG on my PC.

The statement in the JCN is:-

Code:
MbService.logError(this,
                        methodName,
                        RegexFilterNodeMessages.MESSAGE_SOURCE,
                        RegexFilterNodeMessages.INVALID_REGEX,
                        "Invalid regex",
                        new String[] { getRegexPattern().toString() });

Code:



Below is the definition of the message class in the JCN (straight from the Sample code)

Code:
public static class RegexFilterNodeMessages extends ListResourceBundle
  {
    public static final String MESSAGE_SOURCE = RegexFilterNodeMessages.class.getName();                                               
    public static final String INVALID_REGEX = "INVALID_REGEX";
   
    private Object[][] messages  = {{INVALID_REGEX, "%1 is not a valid regular expression." }};

    /* (non-Javadoc)
     * @see java.util.ListResourceBundle#getContents()
     */
    public Object[][] getContents()
    {
      return messages;
    }
  }



Any ideas ?
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Jan 19, 2011 5:00 am    Post subject: Reply with quote

Jedi Knight

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

Hi vvssivakumar and Featherstone,

There are a few bugs in the syslog output functionality of the MbService class. For one, whole strings drop out in the event that some character like a line feed or a carriage return is present in the string. There is a patch available to fix that issue, if this matches your output, open a PMR to receive the patch.

But, you are truly better off using Log4J to do logging anyway. Log4J works from JCN as well as ESQL. My recommendation is not to use the WMB-Log4J support pac but to call Log4J directly. You do not need the support pac to make use of Log4J functionality and the WMB-Log4J support pac also has some unexpected behaviours that you would not want in your production operation.

Good luck.
Lance
_________________
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
mqjeff
PostPosted: Wed Jan 19, 2011 5:38 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

lancelotlinc wrote:
There are a few bugs in the syslog output functionality of the MbService class.


At what specific fixpack level?

And using Log4J instead of MBService does not in any way meet a requirement to "add messages to the syslog", and requires a significant change in monitoring and management practices for a Broker administrator.

So while you may prefer it, it is not best practice.
Back to top
View user's profile Send private message
lancelotlinc
PostPosted: Wed Jan 19, 2011 5:45 am    Post subject: Reply with quote

Jedi Knight

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

The behaviour was observed in Broker runtime 7.0.0.0 and 7.0.0.2. There is an APAR fix to correct the carriage return line feed issue.

You can use log4j to write to syslog, so I don't know why you say its not best practice. Using log4j is an industry defacto standard. I'm sure there would be an army of people that would disagree with you about the best practice part.

We use log4j to write events which get picked up by Tivoli and alert humans when needed. Is this not a best practice? If not, what do you suggest as being the "best practice"?

In fact, under the covers, the WMB product uses log4j for some log output.
_________________
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
Featherstone
PostPosted: Wed Jan 19, 2011 8:50 am    Post subject: Resolved! Reply with quote

Novice

Joined: 18 Oct 2010
Posts: 11

I've actually resolved the issue - 5 minutes after raising a post!

The sample JCN is incorrect and instead of using '%1' in a log message as a marker for an insert, you need to use '{0}'.

The extended ListResourceBundle class is:-

Code:
   public static class MyApplicationFlow_JavaComputeNodeMessages extends ListResourceBundle
   {
     public static final String MESSAGE_SOURCE = MyApplicationFlow_JavaComputeNodeMessages.class.getName();                                               
     public static final String LOGGER_LEVEL = "LOGGER_LEVEL";
   
     private Object[][] messages  = {{LOGGER_LEVEL, "Some info: param1= {0} and  param2 = {1} further text etc." }};
    

     /* (non-Javadoc)
      * @see java.util.ListResourceBundle#getContents()
      */
     public Object[][] getContents()
     {
       return messages;
     }
   }



and the call to the MbService is:-

Code:
         MbService.logInformation("SourceClassName",
                               "evaluate",
                               MyApplicationFlow_JavaComputeNodeMessages.MESSAGE_SOURCE,
                               MyApplicationFlow_JavaComputeNodeMessages.LOGGER_LEVEL,
                               "Logger Level",
                               (new String[] {"MyParam1","MyParam2"}));
                               //new Level[] {LOGGER.getLevel()  });



In the event viewer I get:-


Code:
( MB7BROKER.default ) Java node information: '[MyApplicationFlow_JavaCompute$MyApplicationFlow_JavaComputeNodeMessages:LOGGER_LEVEL]Some info: param1= MyParam1 and  param2 = MyParam2 further text etc.: Logger Level'.   

Information message generated by Java node.   

No user action required. 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MbService.logError
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.