• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

which pattern to use for message conv. and trf.

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simply speaking there are two diff systems which understand diff format.
one system say XXX will send a message throg MQ in a line by line format .. now these line will have say diff keywords which will indicate the nature of the order and what is to be done on that order.
and this will be parsed and understood and then converted into another format SAY to put it to YYY now this format is a string based format ( one full string ) of a specified bytelength .
this is a two way kind where message has to be processed from XXX - understood - parsed - conv to YYY format and viceversa. then againg place it in MQ

there is no GUI involved only trf of message thro MQ from one system to another
 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am going to think out loud here: what you need is a pattern that will do format transformation. So in that sense, you should try the Strategy pattern. You will have different strategies, transform format A to B strategy and transform format B to A strategy. Comments anyone ?
Gavin
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not sure what you gain from using the strategy pattern ?
I would probably start off with the simplest thing possible,

and then see where it lead me.
D.
 
Genie mani
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thnx Don , Gavin
i checked out strategy, but here i have one more thing to think of :
there are fixed keywords that i need to map to
which helps me in identifying values of those keywords in all the specific lines ( since message is sent in a lines format ) then i do the parsing using this mapping and convert it to a string
and viceversa
as DON mentioned it would be quite cumbersome to
have it in a single file ... i wanted to seggregate into small pieces so that any change in format it becomes maintainable
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Genie mani:
there are fixed keywords that i need to map to which helps me in identifying values of those keywords in all the specific lines ( since message is sent in a lines format ) then i do the parsing using this mapping and convert it to a string
and viceversa


I don't really understand this. You have a fixed set of keywords - fine. What do you want to use them for ?
Perhaps a small example would help make it clearer ?
D.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The actual transformation is of little relevance when thinking of extensibility here. If the input can be a bit different, it may as well be a lot different -> let's design accordingly.
What I'm trying to get at is something like the following pseudo-code:

Now, for each new format you can write a new interface extending Transformer or just use Transformer and let the client code do the necessary casts if applicable.
 
Genie mani
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok ,
RAS 1
AM OVR
BUY
500 BBH 83.10
GTC DNR O

PTS 1
the above will be a sample order which comes in form of lines VIA MQ there are several types of such orders , now each type is identified
by specified Keyword like GTC 6th line will indicate simple order where as if it is CXL anywhere in the lines then it is a cancel order
these are keywords to identify types then there are keywords or specific lines to be read for such type of orders its like we need a rules engine kind, when a simple order comes we know which lines to look for since it is given in the format specs , if its a CXL order then we know which lines to look for
line 83.10 in line 6 is quantity etc...
1)so now i need to design a system which will read the format already known for such types where the line information is also read to extract the fields from the lines
2) then use this values and place it one after the other in a single string ( even this is format specified like 6th - 20th char will be quantity so the qty read from the above sample will be placed in this 6-20th char position.
and then this entire process is reversed when i read a string from MQ and then convert it into line format given above....
hope this makes things clearer.....
and thnx for ur replies once again...Lasse, DON
[ May 21, 2003: Message edited by: Genie mani ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So you're actually looking for something more like an implementation approach (how to parse the incoming message, how to detect the format of the incoming message, etc.) than a design pattern (how to support new formats without major changes)?
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cheers for the example, snowed under at the 'mo will try and give you an answer later tonight.
D.
 
Don Kiddick
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought of various more complicated solutions but I eventually ended up on the simplest one.
Something like :

Comments welcome. Hope it helps.
D.
[ May 21, 2003: Message edited by: Don Kiddick ]
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If it works, it's fine.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the number of different tokens/keywords increases, you might probably want to refactor to something like a Map, mapping the Strings to different Strategy objects encapsulating the appropriate action done for it.
 
Genie mani
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnx everyone for ur reply !!!
actually its simple enough to have it in one single class and process the strings.. what i actually wanted was to have seperated functionality like the types i mentioned above i am using STRATEGY pattern this seperates the type
as preuss mentions how can i work out processing these fixed token for conversion,are there any patterns for the same....
 
This guy is skipping without a rope. At least, that's what this tiny ad said:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic