public Long getLong(T key) { return getLong(key, null); }
@Override public DaemonContext create(final String name, final Options options) { final boolean singleton = options.getBoolean(DaemonContext.CreateOption.SINGLETON); return new ConcreteDaemonContext(name, clusterParticipant(name, singleton), singleton, options.getLong(DaemonContext.CreateOption.STOP_TIMEOUT)); } }
protected ConnectionFactory createRemoteConnectionFactory(final Options<CreateContextOption> options) { //TODO: possibly cache the remote cf's? Map<String, Object> transportOpts = new HashMap<>(); transportOpts.put("host", options.getString(CreateContextOption.HOST)); transportOpts.put("port", options.getInt(CreateContextOption.PORT)); if (REMOTE_TYPE_WILDFLY.equals(options.getString(CreateContextOption.REMOTE_TYPE))) { transportOpts.put("http-upgrade-enabled", true); } TransportConfiguration config = new TransportConfiguration("org.hornetq.core.remoting.impl.netty.NettyConnectorFactory", transportOpts); HornetQConnectionFactory hornetQcf = HornetQJMSClient .createConnectionFactoryWithoutHA(options.has(CreateContextOption.XA) ? JMSFactoryType.XA_CF : JMSFactoryType.CF, config); hornetQcf.setReconnectAttempts(options.getInt(CreateContextOption.RECONNECT_ATTEMPTS)); hornetQcf.setRetryInterval(options.getLong(CreateContextOption.RECONNECT_RETRY_INTERVAL)); hornetQcf.setRetryIntervalMultiplier(options.getDouble(CreateContextOption.RECONNECT_RETRY_INTERVAL_MULTIPLIER)); hornetQcf.setMaxRetryInterval(options.getLong(CreateContextOption.RECONNECT_MAX_RETRY_INTERVAL)); // We have to cast for HornetQ 2.3 - the factory object that is returned is both a HornetQConnectionFactory // and a javax.jms.ConnectionFactory, but HornetQConnectionFactory doesn't implement j.j.ConnectionFactory. // With HornetQ 2.4, this cast is redundant. return (ConnectionFactory)hornetQcf; }
protected Trigger initTrigger(String name, Options<ScheduleOption> opts) { TriggerBuilder<Trigger> builder = TriggerBuilder.newTrigger() .withIdentity(name, name()); if (opts.has(AT)) { builder.startAt(opts.getDate(AT)); } else if (opts.has(IN)) { builder.startAt(new java.util.Date(System.currentTimeMillis() + opts.getLong(IN))); } else { builder.startNow(); } if (opts.has(UNTIL)) { builder.endAt(opts.getDate(UNTIL)); } if (opts.has(CRON)) { builder.withSchedule(CronScheduleBuilder.cronSchedule(opts.getString(CRON))); } else if (opts.has(EVERY)) { SimpleScheduleBuilder schedule = SimpleScheduleBuilder.simpleSchedule() .withIntervalInMilliseconds(opts.getInt(EVERY)); if (opts.has(LIMIT)) { schedule.withRepeatCount(opts.getInt(LIMIT) - 1); } else { schedule.repeatForever(); } builder.withSchedule(schedule); } return builder.build(); }
DeliveryMode.PERSISTENT : DeliveryMode.NON_PERSISTENT, opts.getInt(PublishOption.PRIORITY), opts.getLong(PublishOption.TTL, producer.getTimeToLive())); } finally { producer.close();