Example #1
0
        public void SessionAbortedByPartner(
            BOOLEAN isInbound,
            NativeReliableMessaging.IFabricReliableSessionPartitionIdentity partitionId,
            NativeReliableMessaging.IFabricReliableSession session)
        {
            var closingSession = ReliableMessagingSession.FromNative(session);

            var nativeSvcName = partitionId.getServiceName();
            var svcInstance   = NativeTypes.FromNativeUri(nativeSvcName);

            var partitionKeyType = partitionId.getPartitionKeyType();
            var partitionKey     = partitionId.getPartitionKey();

            if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_NONE)
            {
                this.managedCallback.SessionAbortedByPartner(NativeTypes.FromBOOLEAN(isInbound), svcInstance, closingSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_INT64)
            {
                var int64KeyRange = IntegerPartitionKeyRangeFactory.FromNative(partitionKey);
                this.managedCallback.SessionAbortedByPartner(NativeTypes.FromBOOLEAN(isInbound), svcInstance, int64KeyRange, closingSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_STRING)
            {
                this.managedCallback.SessionAbortedByPartner(
                    NativeTypes.FromBOOLEAN(isInbound),
                    svcInstance,
                    NativeTypes.FromNativeString(partitionKey),
                    closingSession);
            }
        }
Example #2
0
        internal static ReliableMessagingSession FromNative(
            NativeReliableMessaging.IFabricReliableSession nativeSession)
        {
            Debug.Assert(null != nativeSession);

            // AppTrace.TraceSource.WriteNoise("ReliableMessagingSession.FromNative");

            return(new ReliableMessagingSession(nativeSession));
        }
Example #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="nativeSession"></param>
        internal ReliableMessagingSession(
            NativeReliableMessaging.IFabricReliableSession nativeSession)
        {
            // AppTrace.TraceSource.WriteNoise("ReliableMessaging.NativeReliableSession.FabricCreateReliableSession");

            // Initialize native reliable session interface pointer.
            // TODO: exception handling
            this.nativeReliableSession = nativeSession;
            Debug.Assert(null != this.nativeReliableSession);
            this.nativeMessageDataFactory = (NativeReliableMessaging.IFabricMessageDataFactory)nativeSession;
        }
Example #4
0
        public int AcceptInboundSession(
            NativeReliableMessaging.IFabricReliableSessionPartitionIdentity partitionId,
            NativeReliableMessaging.IFabricReliableSession session)
        {
            var offeredSession = ReliableMessagingSession.FromNative(session);

            var nativeSvcName = partitionId.getServiceName();
            var svcInstance   = NativeTypes.FromNativeUri(nativeSvcName);

            var result = false;

            var partitionKeyType = partitionId.getPartitionKeyType();
            var partitionKey     = partitionId.getPartitionKey();

            if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_NONE)
            {
                result = this.managedCallback.AcceptInboundSession(svcInstance, offeredSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_INT64)
            {
                var int64KeyRange = IntegerPartitionKeyRangeFactory.FromNative(partitionKey);
                result = this.managedCallback.AcceptInboundSession(svcInstance, int64KeyRange, offeredSession);
            }
            else if (partitionKeyType == NativeTypes.FABRIC_PARTITION_KEY_TYPE.FABRIC_PARTITION_KEY_TYPE_STRING)
            {
                result = this.managedCallback.AcceptInboundSession(svcInstance, NativeTypes.FromNativeString(partitionKey), offeredSession);
            }

            // TODO: if the key is an unknown type should be invalif arg
            // TODO: this whole boolean return API needs update
            if (result)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }