In my application perticular message structure/format are send and received. When I have to send the message, the message should be created on the particular format. I have parse message on perticular message. The message nothing but byte array
To parse the message I have used Preon lib.
I have following problem with :
- Programatically I have to create the byte array for each field.
- When message format get changed I have to change the code.
How can I construct run time message structure and parse the message structure.
The message structure look like this
Message1{
int field_1
char[2] field_2
long filed_3
double filed_4
bit field_5
short field_6
char field_7
}
Message2{
Message1 msg
short field_8
char field_9
}
-
Message structure will be change any time.
-
There are more than 1000 types of messages in the system.
So I am looking for solution in java which will create message and parse from given structure runtime.
If you have sample code, please provide the code sniipet.
I would use an OSGi container (karaf/iPOJO) which allows me to change the code while the application is running. This means you can add fields, change their type and size while the system without bringing down the application.
Note: if you add a field or make a field larger but the code doesn’t support it won’t you lose information?