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 » v8 Patterns and broker schema

Post new topic  Reply to topic
 v8 Patterns and broker schema « View previous topic :: View next topic » 
Author Message
goffinf
PostPosted: Fri Nov 23, 2012 4:05 am    Post subject: v8 Patterns and broker schema Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

version: 8.0.0.1

I am in the process of creating a user defined pattern. When generating the instance I want to give the user of the pattern the ability to create the flow in a broker schema of their choice.

Is there a straight-forward way of doing that ??

I noted that a couple of the default patterns provide parameters for this so I thought I'd check them out. For example the 'MQ one-way' pattern under the 'File Processing/Record Distribution' category has a General parameter :-

Code:

Pattern
parameter         M     C        Default     Description
------------        ---    ---       --------     -------------
Broker schema  No   No       mqsi         If a broker schema is specified, all message flows and ESQL files are created within that schema.....


However, when I generate an instance using this pattern and use a value of 'com.mycompany.myonewaytest' whilst I do get the broker schema 'com.mycompany.myonewaytest' and it does contain the ESQL and msgflow files but ALL of them show the error :-

Code:


Folder 'com.mycompany.myonewaytest' contains a period character and is not a valid broker schema name. Move file named '/ProxyTest1_Flows/com.mycompany.myonewaytest/Error.esql' to a folder named 'com/mycompany/myonewaytest'.



The ESQL files contain the right schema :-

Code:

BROKER SCHEMA com.mycompany.myonewaytest
--  Generated by com.ibm.etools.mft.pattern.sv.sp.ssp Version 1.0
--  $MQSI patternName=com.ibm.etools.mft.pattern.sv.sp.ssp MQSI$
--  $MQSI patternVersion=1.0 MQSI$

DECLARE ErrorLoggingOn EXTERNAL BOOLEAN TRUE;
...


But when I look in the file system, there isn't a folder structure that which nests the parts of the schema (com/mycompany/myonewaytest) but only a single top level folder called /com.mycompany.myonewaytest

Is this a bug, or is this expected behaviour, or is there some other reason that I'm missing ?

Fraser.
Back to top
View user's profile Send private message
mqjeff
PostPosted: Fri Nov 23, 2012 6:36 am    Post subject: Reply with quote

Grand Master

Joined: 25 Jun 2008
Posts: 17447

That sounds like a bug in the pattern implementation, from a design assumption that Broker Schemas will be single entries and not period separated tree structures.

I.e. that it is is built as if you only specify a schema of "MySchema", rather than a schema of "com.mycompany.mygroup.mybusinessfunction.MySchema"...
Back to top
View user's profile Send private message
goffinf
PostPosted: Fri Nov 23, 2012 7:34 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Yes, that was my conclusion, but I was hoping I was wrong.

Interestingly (kinda), if you specify the schema param as using forward slashes : com/mycompany/... the folder structure is created properly in the file system but then of course you get a different error since thats not a valid way to specify the schema in the ESQL file and so on.
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Fri Nov 23, 2012 9:14 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20698
Location: LI,NY

Instead of using "com.mycompany.mytest" did you think about trying
"mycompany.com/mytest" ?
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
goffinf
PostPosted: Fri Nov 23, 2012 9:35 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

fjb_saper wrote:
Instead of using "com.mycompany.mytest" did you think about trying
"mycompany.com/mytest" ?


No I didn't think of that, but when I tried it with the supplied MQ one-way pattern (actually I used com.mycompany/test) I got :-

Code:

Folder 'com.mycompany' contains a period character and is not a valid broker schema name. Move file named '/MQ1Way2_Flows/com.mycompany/test/Error.esql' to a folder named 'com/mycompany/test'.   Error.esql   /MQ1Way2_Flows/com.mycompany/test   Unknown   PackageBuilderMarker


and in the ESQL files :-

Code:

BROKER SCHEMA com.mycompany/test
--  Generated by com.ibm.etools.mft.pattern.fp.rd.mq Version 1.0
--  $MQSI patternName=com.ibm.etools.mft.pattern.fp.rd.mq MQSI$
--  $MQSI patternVersion=1.0 MQSI$


which of course causes the same error as above and a number like this :-
Code:


Unable to find function or procedure named "Main" in ESQL module "Build_Error_Message" in broker schema "com.mycompany."   Error.msgflow   /MQ1Way2_Flows/com.mycompany/test   Unknown   Message Flow Property Reference Problem


So no substantive change it seems.

The best I can make it work at present is to use :-

com/mycompany/test

which created the right folder structure and then manually change the BROKER SCHEMA from / to .
Back to top
View user's profile Send private message
goffinf
PostPosted: Mon Nov 26, 2012 1:36 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

Still struggling a bit with this. What I have is a User Defined Pattern in which I have defined a parameter called brokerSchema.

The exemplar flow and esql are not in any schema.

When the pattern user generates the instance I want the .msgflow and .esql files to be created in a broker schema using the value of the brokerSchema parameter (and copied to the corresponding folder structure).

Using a Java extension class I have managed to sort out all of the nodes that need to use the broker schema (e.g. the Compute module values) and this has resulted in the .esql file being created in the right folder (e.g. com/my company/myservice), but two problems remain :-

1. How to get the .msgflow file copied to the broker schema folder
2. How to get BROKER SCHEMA <value of brokerSchema param> at the top of the .esql file.

Any thoughts ?

Fraser.
Back to top
View user's profile Send private message
goffinf
PostPosted: Thu Nov 29, 2012 8:42 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

For the benefit of anyone interested, I have more or less managed to acheive what I wanted, that is, using a User Define Pattern a flow and it's accompanying esql are created in a project of choice (pattern param), and in a broker schema (also a pattern param) with as many levels as you want (com.mycompany.myservice.xxx.yyy). Unfortunately, for most of this I had to use a Java extension class and some of the code was/is a bit clunky. But it is doable.

I am hoping that fix pack 2 might offer some enhancement for User Defined Patterns. I'll submit my use case to the IBM feedback URL and see what happens (might be too late for 2 I suppose).

One thing I haven't got sorted yet is ... I want to create the pattern instance project in a different location from my current workspace in the file system, and import it to my workspace (we have a separate structure we use for projects under source control and Dev's can use whatever workspace arrangements they want). Whilst I can easily enough create the .msgflow and .esql files wherever I like in the Java extension, there's no way that I've found (yet) of getting the pattern generation to work that way (you just end up with the exemplar flow/esql copied into folders within your current workspace).

For now I'm content enough to just do a <right-click> Move of the project to where I want it, but it would have been nice to do it all as an outcome of running the generate from pattern.
Back to top
View user's profile Send private message
nathanw
PostPosted: Thu Nov 29, 2012 8:51 am    Post subject: Reply with quote

Knight

Joined: 14 Jul 2004
Posts: 550

congrats on this

looks interesting as i was thinking of something like this myself

any chance of some code cuts etc?
_________________
Who is General Failure and why is he reading my hard drive?

Artificial Intelligence stands no chance against Natural Stupidity.

Only the User Trace Speaks The Truth
Back to top
View user's profile Send private message MSN Messenger
goffinf
PostPosted: Fri Nov 30, 2012 8:53 am    Post subject: Reply with quote

Chevalier

Joined: 05 Nov 2005
Posts: 401

nathanw wrote:
congrats on this

looks interesting as i was thinking of something like this myself

any chance of some code cuts etc?


Sure, but keep in mind this is really just my first attempt and I strongly suspect I still have much to learn.

My exemplar project contains a single [simple] flow. It uses User Defined Input/Reply nodes, a number of Label nodes, Computes and so on.

My requirements are :-

- Create a new project based on the exemplar using a name input by the user
- The generated instance (flow+esql) should be created within a Broker schema input by the user
- For all Label nodes the 'Label Name' property needs to be updated to include the chosen broker schema (our convention is to use a label name following the prototype <broker-schema>.purpose, so for example if the exemplar flow has a label node with a label name value of 'sendReply' and the chosen broker schema is 'com.mycompany.myservice', in the generated instance that label would have a label name of 'com.mycompany.myservice.sendReply')
- The ESQL Module property for all Compute nodes need to include the broker schema (similarly to the label nodes described above)

I also want to be able to create the new project in the file system NOT directly under the current workspace, and have it automatically imported into the current workspace. I haven't managed to do that (yet) so for now I will genertae the instance and then just move it to the location I want using the 'Move' action from the project context menu (right-click).

First of all I created a Pattern Authoring project, defined a group to hold my UDPs. I chose my exemplar project as the 'Source Files' and then created 3 parameters in the 'Pattern Configuration'. I'm only going to talk about 2 of these below, they are 'Project Name (pp1)' and 'Target Schema (pp2)'. In the same tab I also added a Java pattern extension class, and it is this class I'm going to highlight below (the rest of the pattern generation stuff works as documented so no need for me to go thru that).

So, to some code snippets (warning: Java is not my most promising skillset) :-

So first up a couple of lines you get for free (self explanatory) :-

Code:

// The location for the generated projects
String location = patternInstanceManager.getWorkspaceLocation();

// The pattern instance name for this generation
String patternInstanceName = patternInstanceManager.getPatternInstanceName();


Get the values of the params I mentioned :-

Code:

String projectName = patternInstanceManager.getParameterValue("pp1");
String brokerSchema = patternInstanceManager.getParameterValue("pp2");


and create a 'slash' replaced and 'underscore' replace versions of the brokerSchema param (these are need when updating the .msgflow file - I am hoping to find a better method but for now this is it) :-

Code:

String brokerSchemaSlash = brokerSchema.replace(".", "/");
String brokerSchemaUnderscore = brokerSchema.replace(".", "_");


get a reference to the message flow itself :-

Code:

MessageFlow msgFlow = null;
msgFlow = patternInstanceManager.getMessageFlow(patternProjectName, patternFlowFileName);


Next, since the exemplar is not in a schema, I need to add a BROKER SCHEMA statement to the .esql file (note: hack alert). I did this just using standard Java IO methods, ... read the .esql file into a String , add the line BROKER SCHEMA <brokerSchema param value>, write the file back out. Here's some of that :-

Code:

String newText = "BROKER SCHEMA " + brokerSchema + "\n" + oldText;

// write changes to temp file
FileWriter writer = new FileWriter(esqlFileTemp);
writer.write(newText);
writer.close();


Now, iterate thru all Compute nodes and update the 'ESQL module' property to include the broker schema :

Code:

ESQLFile esqlFile = new ESQLFile(updatedESQLFileTemp);
esqlFile.setName(patternFlowName);
// Iterate thru all Compute modules and update the ESQL module property to include the broker schema
String esqlName = esqlFile.getName();
Vector<ESQLModule> esqlModules = esqlFile.getEsqlModules();
int moduleCount = esqlModules.size();
String nodeName = null;
ComputeNode computeNode;
if (moduleCount > 0) {
   for (Iterator iterator = esqlModules.iterator(); iterator.hasNext(); ) {
      ESQLModule esqlModule = (ESQLModule) iterator.next();

      nodeName = esqlModule.getEsqlMain().substring(15);
      computeNode = (ComputeNode) msgFlow.getNodeByName(nodeName);
      esqlModule.setBrokerSchema(brokerSchema);
      if (computeNode != null){
         computeNode.setComputeExpression(esqlModule);
      } else {
         System.out.println("Unable to find Compute module for node: " + nodeName + "\n");
      }
   }
} else {
   System.out.println("No ESQL modules found ! ");
}


Now save the .esql file to the fully qualified folder location :-

Code:

esqlFile.setBrokerSchema(brokerSchemaSlash);
esqlFile.save(location + "/" + projectName);


now for the Label nodes :-

Code:

LabelNode labelNode;
String labelNodeName = null;
String labelName = null;
Vector<Node> nodes = msgFlow.getNodes();
for (Iterator iterator = nodes.iterator(); iterator.hasNext(); ) {
   Node node = (Node) iterator.next();
   String nodeType = node.getTypeName();
   if (nodeType == "ComIbmLabelNode"){
      labelNode = (LabelNode) node;
      labelNodeName = labelNode.getNodeName();
      labelName = labelNode.getLabelName();
      labelNode.setLabelName(brokerSchema + "." + labelName);
   }
}


Update the .msgflow file and write it out to the fully qualified folder location. This is the second 'kludgy' part. Essentially when a flow is created or moved into a broker schema three attribute values in the .msgflow file get updated. These are the nsURI and nsPrefix attributes in the EPackage element, and the bundleName attribute of one the translation elements. The nsURI and bundleName values, delimit the broker schema using forward slashes, whereas the nsPrefix uses underscores (hence those 2 variants of the brokerSchema param I created earlier) :-

Code:

<ecore:EPackage xmi:version="2.0" .... nsURI="com/mycompany/myservice/PatternTest22/unittest/commonESQLTest.msgflow"
nsPrefix="com_mycompany_myservice_PatternTest22_unittest_commonESQLTest.msgflow">
...
<translation ... bundleName="com/mycompany/myservice//PatternTest22/unittest/commonESQLTest" .../>


The Java code is similar to that I used earlier to add the BROKER SCHEMA xxx to the .esql file. That is read the .msgflow file and do three string replacements, then write the file back out. I won't bother showing much of this ... I did use a temporary [copy] of the exemplar .msgflow file but thats not overly important:

Code:

String newText = oldText.replaceFirst("nsURI=\"" + patternFlowNameTemp, "nsURI=\"" + brokerSchemaSlash + "/" + patternFlowName);
newText = newText.replaceFirst("nsPrefix=\"" + patternFlowNameTemp, "nsPrefix=\"" + brokerSchemaUnderscore + "_" + patternFlowName);
newText = newText.replaceFirst("bundleName=\"" + patternFlowNameTemp, "bundleName=\"" + brokerSchemaSlash + "/" + patternFlowName);


Now that those values have been updated, writing the resulting .msgflow file to the correct location in the file system is taken care of by :-

Code:

MessageFlow renderedMsgFlow = FlowRendererMSGFLOW.read(renderedMsgFlowFileTemp);
renderedMsgFlow.setName(patternFlowName);
FlowRendererMSGFLOW.write(renderedMsgFlow, location + "/" + projectName);


After all that it was just a case of tidying up temporary files and removing the original .msgflow and .esql file copied by the template plug-in. The msgflow file can be removed using :-

Code:

patternInstanceManager.removeMessageFlow(msgFlow);


Whereas the .esql file can be deleted using standard Java IO.

So thats about it. Hope this provides some useful info for anyone else attempting this. And if there are better approaches, please feel free to suggest them.

Regards

Fraser.
Back to top
View user's profile Send private message
araaawasdasdasdasd
PostPosted: Mon Sep 01, 2014 4:26 am    Post subject: Reply with quote

Newbie

Joined: 27 Aug 2014
Posts: 3

Hi Fraser,

I was performing the same task as u hav done previously.
I'm stuck in the part where the edited String "newText" is converted back to a messageFlow. I'm unaware of the conversion.
Can u please ellaborate in the last part ?

Tasks I have done:
1.Read the messageFlow to a string.
2.Performed the essential string manipulations for user defined Schema.
Im stuck after that "How do I make the changes that I have done in the string replicate in the messageFlow?"
How do I convert the string to a messageFlow?

Your Comment:

The Java code is similar to that I used earlier to add the BROKER SCHEMA xxx to the .esql file. That is read the .msgflow file and do three string replacements, then write the file back out. I won't bother showing much of this ... I did use a temporary [copy] of the exemplar .msgflow file but thats not overly important:

Now that those values have been updated, writing the resulting .msgflow file to the correct location in the file system is taken care of by :-
"Code:

MessageFlow renderedMsgFlow = FlowRendererMSGFLOW.read(renderedMsgFlowFileTemp);
renderedMsgFlow.setName(patternFlowName);
FlowRendererMSGFLOW.write(renderedMsgFlow, location + "/" + projectName); "


My Doubt:
"That is read the .msgflow file and do three string replacements, then write the file back out."
How do I write the file back out?
Back to top
View user's profile Send private message
fjb_saper
PostPosted: Mon Sep 01, 2014 5:32 am    Post subject: Reply with quote

Grand High Poobah

Joined: 18 Nov 2003
Posts: 20698
Location: LI,NY

I hope you also tried with putting your source pattern project into a broker schema. I fear that if you did not the system assumes you did not want to use a broker schema and does not offer you one for the target.

Also make sure you are able to set the broker schema as one of the generation parameters.

Have fun
_________________
MQ & Broker admin
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » v8 Patterns and broker schema
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.