Author |
Message
|
marwan |
Posted: Mon Mar 23, 2015 9:11 am Post subject: global caching |
|
|
Newbie
Joined: 23 Mar 2015 Posts: 5
|
hi all ,
i m a new here , and i want to ask if anyone has done the global catching in wmb ???
please share with me the knowledge .
 |
|
Back to top |
|
 |
Vitor |
Posted: Mon Mar 23, 2015 9:16 am Post subject: Re: global caching |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
marwan wrote: |
i want to ask if anyone has done the global catching in wmb |
Yes I have.
marwan wrote: |
please share with me the knowledge |
What "knowledge"?
- Does it work? Yes
- How do I set it up? As described in the InfoCenter
- How do I use it? As described in the InfoCenter
That's about as much knowledge as you need. Unless you have a specific question....? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
marwan |
Posted: Mon Mar 23, 2015 1:01 pm Post subject: thanks |
|
|
Newbie
Joined: 23 Mar 2015 Posts: 5
|
can u please share the links , i need ( step by step explanation)
and thanks for replaying back |
|
Back to top |
|
 |
mqjeff |
Posted: Mon Mar 23, 2015 1:09 pm Post subject: Re: thanks |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
marwan wrote: |
can u please share the links , i need ( step by step explanation) |
have you considered looking in the Knowledge Center? |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Mar 23, 2015 1:09 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Look in your toolkit under the samples & Tutorials item in the Help Menu.
Then go look for the Coordinated Request - Reply Sample.
This should give you all you need.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
marwan |
Posted: Mon Mar 23, 2015 7:56 pm Post subject: |
|
|
Newbie
Joined: 23 Mar 2015 Posts: 5
|
Code: |
hi this is my code see
the idea simple to read xml file and store all information in global caching then store it in database , if u want to read the same xml file it will check if this file in the global caching or otherwise it will put it inside the database |
Code: |
first flow ESQL node
CREATE COMPUTE MODULE LoadGlobalCache_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
--CALL CopyEntireMessage();
DECLARE blnResult BOOLEAN TRUE;
DECLARE blnMapResult BOOLEAN;
DECLARE refMap REFERENCE TO InputRoot.XMLNSC.*[1];
MOVE refMap NEXTSIBLING;
MOVE refMap FIRSTCHILD;
WHILE(LASTMOVE(refMap)) DO
SET blnMapResult = addMapToCache(refMap);
IF blnMapResult = FALSE THEN
SET blnResult = FALSE;
END IF;
MOVE refMap NEXTSIBLING REPEAT TYPE NAME;
END WHILE;
SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration) = ' ';
SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Version = '1.0';
SET OutputRoot.XMLNSC.(XMLNSC.XmlDeclaration)*.(XMLNSC.Attribute)Encoding = 'UTF-8';
IF blnResult THEN
SET OutputRoot.XMLNSC.Output.Result = 'Cache has been refreshed successfully';
ELSE
SET OutputRoot.XMLNSC.Output.Result = 'Error encountered while refreshing cache';
END IF;
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CopyEntireMessage() BEGIN
SET OutputRoot = InputRoot;
END;
END MODULE;
CREATE PROCEDURE getCacheValue(IN chrMapName CHARACTER, IN chrKey CHARACTER) RETURNS CHARACTER
BEGIN
DECLARE chrResult CHARACTER;
SET chrResult = getCacheValueFromWXS(chrMapName,chrKey);
IF (TRIM(chrResult) IS NULL OR TRIM(chrResult) ='' ) THEN
THROW USER EXCEPTION MESSAGE 2999 VALUES('Failed to retrieve cache') ;
END IF;
RETURN chrResult;
END;
CREATE PROCEDURE getCacheValueFromWXS(IN chrMapName CHARACTER, IN chrKey CHARACTER)
RETURNS CHARACTER
LANGUAGE JAVA
EXTERNAL NAME "Utilities.CacheUtil.getValue";
CREATE PROCEDURE addMapToCache(IN refMap REFERENCE)
RETURNS BOOLEAN
LANGUAGE JAVA
EXTERNAL NAME "Utilities.CacheUtil.addMap";
Second Java compute node
import com.ibm.broker.javacompute.MbJavaComputeNode;
import com.ibm.broker.plugin.MbException;
import com.ibm.broker.plugin.MbGlobalMap;
import com.ibm.broker.plugin.MbMessage;
import com.ibm.broker.plugin.MbMessageAssembly;
import com.ibm.broker.plugin.MbOutputTerminal;
import com.ibm.broker.plugin.MbUserException;
import com.ibm.jvm.dtfjview.Output;
public class Global_ff_JavaCompute extends MbJavaComputeNode {
public void evaluate(MbMessageAssembly contact admin) throws MbException {
MbMessage message = contact admin.getMessage();
//stored in the global cache
String got = message.getRootElement().getFirstElementByPath("/M/NAME/").getValueAsString();
// save
byte[] lot = message.getRootElement().getFirstElementByPath("/M/").toBitstream(
null, null, null,
0, 0, 0
);
// Put key and data into map
MbGlobalMap.getGlobalMap().put(got, lot);
}}
|
help please ???????????????
 |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Mar 24, 2015 4:42 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
So did you look at all at the sample?  _________________ MQ & Broker admin |
|
Back to top |
|
 |
marwan |
Posted: Tue Mar 24, 2015 5:40 am Post subject: |
|
|
Newbie
Joined: 23 Mar 2015 Posts: 5
|
yes sir , but im dealing with database .
the example is shown a simple thing |
|
Back to top |
|
 |
kimbert |
Posted: Tue Mar 24, 2015 7:04 am Post subject: |
|
|
 Jedi Council
Joined: 29 Jul 2003 Posts: 5542 Location: Southampton
|
You have posted your code. Now you need to explain what the problem is. _________________ Before you criticize someone, walk a mile in their shoes. That way you're a mile away, and you have their shoes too. |
|
Back to top |
|
 |
Vitor |
Posted: Tue Mar 24, 2015 7:23 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
marwan wrote: |
yes sir , but im dealing with database . |
Not in the code you posted.
Also:
marwan wrote: |
the idea simple to read xml file and store all information in global caching then store it in database , if u want to read the same xml file it will check if this file in the global caching or otherwise it will put it inside the database |
Not only does this not match the posted code, this is an odd thing to do. Usually one would get data stored in a database and store it in a cache, not cache the data and then put it. You need to be clearer about what you're trying to do.
marwan wrote: |
i need ( step by step explanation) |
Of what? You've posted code which shows at least a basic understanding of the IIB cache & how to use it, even if your design's a bit confusing.So what's the problem? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|