quartz.net - context.Trigger.JobDataMap values via xml configuration -


in quartz_jobs.xml, can set parameters job.....

   <job>         <name>myjob</name>         <group>myjob</group>         <description>my job</description>         <job-type>myassembly.myjob, myassembly</job-type>         <durable>true</durable>         <recover>false</recover>         <job-data-map>             <entry>                 <key>jobmapdatakeyone</key>                 <value>jobmapdatavalueone</value>             </entry>             <entry>                 <key>jobmapdatakeytwo</key>                 <value>jobmapdatavaluetwo</value>             </entry>         </job-data-map>      </job> 

and here code:

public class myjob: ijob {      public virtual void execute(ijobexecutioncontext context)     {          jobkey key = context.jobdetail.key;          jobdatamap jbdatamap = context.jobdetail.jobdatamap;          string jobmapdatavalueone = jbdatamap.getstring("jobmapdatakeyone");         string jobmapdatavaluetwo = jbdatamap.getstring("jobmapdatakeyone");      } } 

now, can "code job , trigger" (not using .xml setup) (code not seen).... , can below work. (and have populated values triggerparameter001value , triggerparameter002value ).

public class myjob: ijob {      public virtual void execute(ijobexecutioncontext context)     {          jobkey key = context.jobdetail.key;          jobdatamap trgdatamap = context.trigger.jobdatamap;          string triggerparameter001value = trgdatamap.getstring("triggerparameter001key");         string triggerparameter002value = trgdatamap.getstring("triggerparameter002key");      } } 

but don't see way pass parameters trigger...defined in xml.

i searched

"trigger-data-map" 

and

"jobtrigger-data-map" 

to no avail.

i fished around "http://quartznet.sourceforge.net/jobschedulingdata" xsd well. missing in xml? missing something?

ok. 1 sneaky!

the below not work: (note position of "job-data-map" element ~under "simple" element)

   <job>         <name>myjob</name>         <group>myjobgroup</group>         <description>my job</description>         <job-type>myassembly.myjob, myassembly</job-type>         <durable>true</durable>         <recover>false</recover>         <job-data-map>             <entry>                 <key>jobmapdatakeyone</key>                 <value>jobmapdatavalueone</value>             </entry>             <entry>                 <key>jobmapdatakeytwo</key>                 <value>jobmapdatavaluetwo</value>             </entry>         </job-data-map>       </job>          <trigger>              <simple>                 <name>mytrigger</name>                 <group>mytriggerjobgroup</group>                 <description>mytriggerdescription</description>                 <job-name>myjob</job-name>                 <job-group>myjobgroup</job-group>                   <!--<start-time>1982-06-28t18:15:00.0z</start-time>-->                 <!--<end-time>2020-05-04t18:13:51.0z</end-time>-->                 <misfire-instruction>smartpolicy</misfire-instruction>                 <!-- repeat indefinitely every 10 seconds -->                 <repeat-count>-1</repeat-count>                 <repeat-interval>5000</repeat-interval>                   <job-data-map>                     <entry>                         <key>triggerparameter001key</key>                         <value>triggerparameter001value</value>                     </entry>                     <entry>                         <key>triggerparameter002key</key>                         <value>triggerparameter002value</value>                     </entry>                  </job-data-map>               </simple>          </trigger> 

the above xml giving me error this:

quartz.plugin.xml.xmlschedulingdataprocessorplugin.processfile error error scheduling jobs: element 'simple' in namespace 'http://quartznet.sourceforge.net/jobschedulingdata' has invalid child element 'job-data-map' in namespace 'http://quartznet.sourceforge.net/jobschedulingdata'.

........................

the below work (note position change of "job-data-map" (still under "simple" element, moved "up" some)

   <job>         <name>myjob</name>         <group>myjobgroup</group>         <description>my job</description>         <job-type>myassembly.myjob, myassembly</job-type>         <durable>true</durable>         <recover>false</recover>         <job-data-map>             <entry>                 <key>jobmapdatakeyone</key>                 <value>jobmapdatavalueone</value>             </entry>             <entry>                 <key>jobmapdatakeytwo</key>                 <value>jobmapdatavaluetwo</value>             </entry>         </job-data-map>       </job>          <trigger>              <simple>                 <name>mytrigger</name>                 <group>mytriggerjobgroup</group>                 <description>mytriggerdescription</description>                 <job-name>myjob</job-name>                 <job-group>myjobgroup</job-group>                   <job-data-map>                     <entry>                         <key>triggerparameter001key</key>                         <value>triggerparameter001value</value>                     </entry>                     <entry>                         <key>triggerparameter002key</key>                         <value>triggerparameter002value</value>                     </entry>                  </job-data-map>                    <!--<start-time>1982-06-28t18:15:00.0z</start-time>-->                 <!--<end-time>2020-05-04t18:13:51.0z</end-time>-->                 <misfire-instruction>smartpolicy</misfire-instruction>                 <!-- repeat indefinitely every 10 seconds -->                 <repeat-count>-1</repeat-count>                 <repeat-interval>5000</repeat-interval>                </simple>          </trigger> 

why?

the xsd uses abstracttype

  <xs:complextype name="abstracttriggertype" abstract="true">     <xs:annotation>       <xs:documentation>common trigger definitions</xs:documentation>     </xs:annotation>     <xs:sequence>       <xs:element name="name" type="xs:string" />       <xs:element name="group" type="xs:string" minoccurs="0" />       <xs:element name="description" type="xs:string" minoccurs="0" />       <xs:element name="job-name" type="xs:string" />       <xs:element name="job-group" type="xs:string" minoccurs="0" />       <xs:element name="priority" type="xs:nonnegativeinteger" minoccurs="0" />       <xs:element name="calendar-name" type="xs:string" minoccurs="0" />       <xs:element name="job-data-map" type="job-data-maptype" minoccurs="0" />      <xs:complextype name="simpletriggertype">     <xs:annotation>       <xs:documentation>define simpletrigger</xs:documentation>     </xs:annotation>     <xs:complexcontent>       <xs:extension base="abstracttriggertype">         <xs:sequence>           <xs:element name="misfire-instruction" type="simple-trigger-misfire-instructiontype" minoccurs="0" />           <xs:sequence minoccurs="0">             <xs:element name="repeat-count" type="repeat-counttype" />             <xs:element name="repeat-interval" type="xs:nonnegativeinteger" />           </xs:sequence> 

so part of abstract has defined ~before~ of concrete properties.

that sneaky!


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -