Example #1
0
        public void Launch()
        {
            Context.Logger.Info("[BasicBolt] Launch ...");
            ApacheStorm.ctx = new BoltContext();
            IPlugin iPlugin = this._createDelegate(ApacheStorm.ctx);

            if (!(iPlugin is IBasicBolt))
            {
                Context.Logger.Error("[BasicBolt] newPlugin must return IBasicBolt!");
            }
            this._bolt = (IBasicBolt)iPlugin;

            //call Prepare method.
            this._bolt.Prepare(Context.Config, Context.TopologyContext);

            while (true)
            {
                StormTuple tuple = ApacheStorm.ReadTuple();
                if (tuple.IsHeartBeatTuple())
                {
                    ApacheStorm.Sync();
                }
                else
                {
                    try
                    {
                        this._bolt.Execute(tuple);
                        ApacheStorm.ctx.Ack(tuple);
                    }
                    catch (Exception ex)
                    {
                        Context.Logger.Error(ex.ToString());
                        ApacheStorm.ctx.Fail(tuple);
                    }
                }
            }
        }
        public void Launch()
        {
            Context.Logger.Info("[BasicBolt] Launch ...");
            ApacheStorm.ctx = new BoltContext();
            IPlugin iPlugin = this._createDelegate(ApacheStorm.ctx);
            if (!(iPlugin is IBasicBolt))
            {
                Context.Logger.Error("[BasicBolt] newPlugin must return IBasicBolt!");
            }
            this._bolt = (IBasicBolt)iPlugin;

            //call Prepare method.
            this._bolt.Prepare(Context.Config, Context.TopologyContext);

            while (true)
            {
                StormTuple tuple = ApacheStorm.ReadTuple();
                if (tuple.IsHeartBeatTuple())
                    ApacheStorm.Sync();
                else
                {
                    try
                    {
                        this._bolt.Execute(tuple);
                        ApacheStorm.ctx.Ack(tuple);
                    }
                    catch (Exception ex)
                    {
                        Context.Logger.Error(ex.ToString());
                        ApacheStorm.ctx.Fail(tuple);
                    }
                }
            }
        }