001: /*
002: * MessageQueueClient: The message queue client library
003: * Copyright (C) 2006 Rift IT Contracting
004: *
005: * This library is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU Lesser General Public
007: * License as published by the Free Software Foundation; either
008: * version 2.1 of the License, or (at your option) any later version.
009: *
010: * This library is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
013: * Lesser General Public License for more details.
014: *
015: * You should have received a copy of the GNU Lesser General Public
016: * License along with this library; if not, write to the Free Software
017: * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
018: *
019: * Message.java
020: */
021:
022: // package path
023: package com.rift.coad.daemon.messageservice;
024:
025: // java imports
026: import java.io.Serializable;
027: import java.util.Date;
028: import java.util.Enumeration;
029: import java.util.List;
030:
031: /**
032: * The definition of the message object.
033: *
034: * @author Brett Chaldecott
035: */
036: public interface Message extends Serializable {
037:
038: /**
039: * A message will get delivered to a point defined by a JNDI URL.
040: */
041: public final static int POINT_TO_POINT = 1;
042:
043: /**
044: * A message will get delivered to the first available service with a
045: * matching service name.
046: */
047: public final static int POINT_TO_SERVICE = 2;
048:
049: /**
050: * A message will get delivered to all services within a coadunation cluster
051: * that match the service name.
052: */
053: public final static int POINT_TO_MULTI_SERVICE = 3;
054:
055: /**
056: * This state flag indicates that a message is undelivered.
057: */
058: public final static int UNDELIVERED = 1;
059:
060: /**
061: * The message has been delivered to its destination.
062: */
063: public final static int DELIVERED = 2;
064:
065: /**
066: * The message could not be delivered to its destination.
067: */
068: public final static int UNDELIVERABLE = 3;
069:
070: /**
071: * A warning
072: */
073: public final static int WARN = 1;
074:
075: /**
076: * An error.
077: */
078: public final static int ERROR = 2;
079:
080: /**
081: * A critical error.
082: */
083: public final static int CRITICAL = 3;
084:
085: /**
086: * This method returns the id of this message object.
087: *
088: * @return The id of the message object.
089: */
090: public String getMessageId();
091:
092: /**
093: * This method returns the date this message was created.
094: *
095: * @return The date message was created.
096: */
097: public Date getCreated();
098:
099: /**
100: * This is the number of retries this message has had.
101: *
102: * @return The number of retries performed by this message.
103: */
104: public int getRetries();
105:
106: /**
107: * This method increments the retry count on this object.
108: */
109: public void incrementRetries();
110:
111: /**
112: * This method will return the last processed date.
113: */
114: public Date getProcessedDate();
115:
116: /**
117: * This method sets the processed date.
118: *
119: * @param processedDate The processed date of the message.
120: */
121: public void setProcessedDate(Date processedDate);
122:
123: /**
124: * This method returns the creator of this message.
125: */
126: public String getMessageCreater();
127:
128: /**
129: * This method returns the ID of the session that created this message.
130: *
131: * @return The string containing the id of the session that created this
132: * message.
133: */
134: public String getSessionId();
135:
136: /**
137: * This method returns the list of user principals assigned to this message.
138: *
139: * @return The list of user principals assigned to this message.
140: */
141: public List getMessagePrincipals();
142:
143: /**
144: * This method returns the type of message that this object represents.
145: *
146: * @return The type of object being wrapped.
147: */
148: public int getMessageType();
149:
150: /**
151: * This method sets the type of message that this object represents.
152: *
153: * @param messageType The type of object being wrapped.
154: */
155: public void setMessageType(int messageType);
156:
157: /**
158: * This method will return the URL string for this message if this is a
159: * point to point message.
160: *
161: * @return The string containing the Target URL.
162: * @exception MessageServiceException
163: * @exception InvalidMessageType
164: */
165: public String getTarget() throws MessageServiceException,
166: InvalidMessageType;
167:
168: /**
169: * This method sets the target of the message.
170: *
171: * @param target The string containing the Target URL.
172: * @exception MessageServiceException
173: * @exception InvalidMessageType
174: */
175: public void setTarget(String target)
176: throws MessageServiceException, InvalidMessageType;
177:
178: /**
179: * This method returns the list of services.
180: *
181: * @return The string array list of services.
182: * @exception MessageServiceException
183: * @exception InvalidMessageType
184: */
185: public String[] getServices() throws MessageServiceException,
186: InvalidMessageType;
187:
188: /**
189: * This method returns the list of services this message targeted at.
190: *
191: * @param services The list of services.
192: * @exception MessageServiceException
193: * @exception InvalidMessageType
194: */
195: public void setServices(String[] services)
196: throws MessageServiceException, InvalidMessageType;
197:
198: /**
199: * This method returns the from URL of a message.
200: *
201: * @return The string containing the from URL.
202: * @exception MessageServiceException
203: */
204: public String getFrom() throws MessageServiceException;
205:
206: /**
207: * This method returns the from address of the message.
208: *
209: * @return The from address of the message.
210: * @exception MessageServiceException
211: */
212: public void setFrom(String from) throws MessageServiceException;
213:
214: /**
215: * This method returns the reply to URL, it can be different from the from
216: * URL.
217: *
218: * @return The string containing the from URL.
219: * @exception MessageServiceException
220: */
221: public String getReplyTo() throws MessageServiceException;
222:
223: /**
224: * This method returns the reply to URL, it can be different from the from
225: * URL.
226: *
227: * @return The string containing the from URL.
228: * @exception MessageServiceException
229: */
230: public void setReplyTo(String replyTo)
231: throws MessageServiceException;
232:
233: /**
234: * This method gets the target named queue.
235: *
236: * @return The string containing the Queue name.
237: * @exception MessageServiceException
238: */
239: public String getTargetNamedQueue() throws MessageServiceException;
240:
241: /**
242: * This method sets the target named queue.
243: *
244: * @param name The string containing the Queue name.
245: * @exception MessageServiceException
246: */
247: public void setTargetNamedQueue(String name)
248: throws MessageServiceException;
249:
250: /**
251: * This will only be set if the reply service is not a daemon, but an
252: * external process.
253: *
254: * @return The string containing the Queue name.
255: * @exception MessageServiceException
256: */
257: public String getReplyNamedQueue() throws MessageServiceException;
258:
259: /**
260: * This will only be set if the reply service is not a daemon, but an
261: * external process.
262: *
263: * @param name The string containing the Queue name.
264: * @exception MessageServiceException
265: */
266: public void setReplyNamedQueue(String name)
267: throws MessageServiceException;
268:
269: /**
270: * This method returns the value of the reply flag. TRUE if it should reply
271: * FALSE if it should not.
272: *
273: * @return TRUE if this message must reply, FALSE if not.
274: * @exception MessageServiceException
275: */
276: public boolean getReply() throws MessageServiceException;
277:
278: /**
279: * This method sets the reply flag.
280: *
281: * @param value TRUE if a reply is required, FALSE if not.
282: * @exception MessageServiceException
283: */
284: public void setReply(boolean value) throws MessageServiceException;
285:
286: /**
287: * This message returns the priority of this message.
288: *
289: * @return The int indicating the priority of this message.
290: * @exception MessageServiceException
291: */
292: public int getPriority();
293:
294: /**
295: * This method sets the priority of the message.
296: *
297: * @param priority The priority of the message.
298: * @exception MessageServiceException
299: */
300: public void setPriority(int priority)
301: throws MessageServiceException;
302:
303: /**
304: * This method sets the correlation id for this message. It is the external
305: * identifier for this message.
306: *
307: * @param id The id that will be used as the correlation id.
308: * @exception MessageServiceException
309: */
310: public void setCorrelationId(String id)
311: throws MessageServiceException;
312:
313: /**
314: * The external correlation id for this message.
315: *
316: * @return The string containing the correllation ID.
317: * @exception MessageServiceException
318: */
319: public String getCorrelationId() throws MessageServiceException;
320:
321: /**
322: * This clears the body of the message.
323: *
324: * @exception MessageServiceException
325: */
326: public void clearBody() throws MessageServiceException;
327:
328: /**
329: * This method clears the properties assigned to this message.
330: *
331: * @exception MessageServiceException
332: */
333: public void clearProperties() throws MessageServiceException;
334:
335: /**
336: * This method returns true if the property is found.
337: *
338: * @return TRUE if the property is found, FALSE if not.
339: * @param name The name of the property.
340: * @exception MessageServiceException
341: */
342: public boolean containsProperty(String name)
343: throws MessageServiceException;
344:
345: /**
346: * This method returns the boolean property value for the requested name.
347: *
348: * @return The value of the boolean property.
349: * @param name The name of the property.
350: * @exception MessageServiceException
351: * @exception InvalidProperty
352: */
353: public boolean getBooleanProperty(String name)
354: throws MessageServiceException, InvalidProperty;
355:
356: /**
357: * This method returns the byte property value for the requested name.
358: *
359: * @return The value of the byte property.
360: * @param name The name of the property.
361: * @exception MessageServiceException
362: * @exception InvalidProperty
363: */
364: public byte getByteProperty(String name)
365: throws MessageServiceException, InvalidProperty;
366:
367: /**
368: * This method returns the double property value for the requested name.
369: *
370: * @return The value of the byte property.
371: * @param name The name of the property.
372: * @exception MessageServiceException
373: * @exception InvalidProperty
374: */
375: public double getDoubleProperty(String name)
376: throws MessageServiceException, InvalidProperty;
377:
378: /**
379: * This method returns the float property value for the requested name.
380: *
381: * @return The value of the float property.
382: * @param name The name of the property.
383: * @exception MessageServiceException
384: * @exception InvalidProperty
385: */
386: public float getFloatProperty(String name)
387: throws MessageServiceException, InvalidProperty;
388:
389: /**
390: * This method returns the int property value for the requested name.
391: *
392: * @return The value of the int property.
393: * @param name The name of the property.
394: * @exception MessageServiceException
395: * @exception InvalidProperty
396: */
397: public int getIntProperty(String name)
398: throws MessageServiceException, InvalidProperty;
399:
400: /**
401: * This method returns the long property value for the requested name.
402: *
403: * @return The value of the long property.
404: * @param name The name of the property.
405: * @exception MessageServiceException
406: * @exception InvalidProperty
407: */
408: public long getLongProperty(String name)
409: throws MessageServiceException, InvalidProperty;
410:
411: /**
412: * This method returns the object property value for the requested name.
413: *
414: * @return The value of the object property.
415: * @param name The name of the property.
416: * @exception MessageServiceException
417: * @exception InvalidProperty
418: */
419: public Object getObjectProperty(String name)
420: throws MessageServiceException, InvalidProperty;
421:
422: /**
423: * This method returns the string property value for the requested name.
424: *
425: * @return The value of the string property.
426: * @param name The name of the property.
427: * @exception MessageServiceException
428: * @exception InvalidProperty
429: */
430: public String getStringProperty(String name)
431: throws MessageServiceException, InvalidProperty;
432:
433: /**
434: * This method returns the value of the property.
435: *
436: * @return The value of the property.
437: * @param name The name of the property.
438: * @exception MessageServiceException
439: * @exception InvalidProperty
440: */
441: public Object getPropertyValue(String name)
442: throws MessageServiceException, InvalidProperty;
443:
444: /**
445: * This method returns the string property value for the requested name.
446: *
447: * @return The list of property names
448: * @exception MessageServiceException
449: */
450: public Enumeration getPropertyNames()
451: throws MessageServiceException;
452:
453: /**
454: * This method returns true if the specified property exits.
455: *
456: * @return TRUE if the property exists, FALSE if not.
457: * @param name The name of the property to look for.
458: * @exception MessageServiceException
459: */
460: public boolean propertyExists(String name)
461: throws MessageServiceException;
462:
463: /**
464: * This method sets the boolean property value for the name.
465: *
466: * @param name The name of the property.
467: * @param value The value of the boolean property.
468: * @exception MessageServiceException
469: */
470: public void setBooleanProperty(String name, boolean value)
471: throws MessageServiceException;
472:
473: /**
474: * This method sets the byte property value for the name.
475: *
476: * @param name The name of the property.
477: * @param value The value of the byte property.
478: * @exception MessageServiceException
479: */
480: public void setByteProperty(String name, byte value)
481: throws MessageServiceException;
482:
483: /**
484: * This method sets the double property value for the name.
485: *
486: * @param name The name of the property.
487: * @param value The value of the double property.
488: * @exception MessageServiceException
489: */
490: public void setDoubleProperty(String name, double value)
491: throws MessageServiceException;
492:
493: /**
494: * This method sets the float property value for the name.
495: *
496: * @param name The name of the property.
497: * @param value The value of the float property.
498: * @exception MessageServiceException
499: */
500: public void setFloatProperty(String name, float value)
501: throws MessageServiceException;
502:
503: /**
504: * This method set the int property value for the name.
505: *
506: * @param name The name of the property.
507: * @param value The value of the int property.
508: * @exception MessageServiceException
509: */
510: public void setIntProperty(String name, int value)
511: throws MessageServiceException;
512:
513: /**
514: * This method sets the long property value for the name.
515: *
516: * @param name The name of the property.
517: * @return value The new long value.
518: * @exception MessageServiceException
519: */
520: public void setLongProperty(String name, long value)
521: throws MessageServiceException;
522:
523: /**
524: * This method returns the object property value for the name.
525: *
526: * @param name The name of the property.
527: * @param value The new object value to set.
528: * @exception MessageServiceException
529: * @exception InvalidProperty
530: */
531: public void setObjectProperty(String name, Object value)
532: throws MessageServiceException;
533:
534: /**
535: * This method sets the string property value for the name.
536: *
537: * @param name The name of the property.
538: * @return value The new string value to set.
539: * @exception MessageServiceException
540: */
541: public void setStringProperty(String name, String value)
542: throws MessageServiceException;
543:
544: /**
545: * This method sets the value of the property.
546: *
547: * @param name The name of the property.
548: * @param value The property value.
549: * @exception MessageServiceException
550: * @exception InvalidProperty
551: */
552: public void setPropertyValue(String name, Object value)
553: throws MessageServiceException, InvalidProperty;
554:
555: /**
556: * This method acknowledges that this message has been successfully
557: * processed by a target.
558: *
559: * @exception MessageServiceException
560: */
561: public void acknowledge() throws MessageServiceException;
562:
563: /**
564: * This method returns the value of the acknowledged flag for this message.
565: *
566: * @return TRUE if acknowleded, FALSE if not.
567: * @exception MessageServiceException
568: */
569: public boolean isAcknowledged() throws MessageServiceException;
570:
571: /**
572: * This method returns the current state of this message.
573: *
574: * @return The current state of this message.
575: * @exception MessageServiceException
576: */
577: public int getState() throws MessageServiceException;
578:
579: /**
580: * This method returns list of errors
581: */
582: public List getErrors() throws MessageServiceException;
583:
584: /**
585: * This method adds an error to the list of errors for this message.
586: *
587: * @param level The level of the error.
588: * @param msg The message associated with the error.
589: */
590: public void addError(int level, String msg)
591: throws MessageServiceException;
592: }
|